|
From: Ioannis V. <no...@ya...> - 2001-04-07 12:47:01
|
In C: #include <stdlib.h> int *p=malloc(sizeof(*p)); /* Allocates one int in free store */ *p=5; /* assigns the value 5. */ free(p); /* frees the allocated memory */ p=malloc(10*sizeof(*p)); /* or p=malloc(10*sizeof(int)); they are both the same */ /* Allocates an arrray of 10 integers in free store */ p[0]=5; p[7]=8; free(p); ----------------------------------------------------------------- In C++: #include <new> int *p=new int; *p=8; delete p; p=new int[10]; p[0]=7; p[1]=8; delete[] p; Ioannis * Ioannis Vranos * Programming pages: http://members.nbci.com/noicys * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of > Nathan Smith > Sent: Friday, April 06, 2001 2:21 PM > To: dev...@li... > Subject: Re: [Dev-C++] Extending an array > > > Know any URLs with examples on how to do it? I am still learning > all this... |