On Saturday 13 December 2003 00:15, Aryan Ameri wrote:
> On Friday 12 December 2003 22:05, Arash Partow wrote:
> > Hi Aryan,
> >
> > There are 2 important methods malloc and realloc
> > malloc allocated memory and realloc as its name
> > suggests allow you to re-allocate more memory from the OS.
> >
> >
> > ie:
> >
> > /*
> > create dynamic array, guess an initial size in your case....
> > */
> >
> > int myArraySize = 123;
> > char* myArray = (char*)malloc(sizeof(char)*myArray);
> >
> > if(myArray == NULL)
> > {
> > printf("!-ERROR-! System could not allocate memory...\n");
> > }
> > .
> > .
> > .
> > now lets say you want to add more to the array but you've
> > reached the limit of the array.
> >
> > int additionalLength = 123;
> > if ((myArray =
> > (char*)realloc(myArray,sizeof(char)*(myArraySize+additionalLength))
> > == NULL) {
> > printf("!-ERROR-! System could not re-allocate memory...\n");
> > }
> >
> > .
> > .
> > .
> >
> >
> > If you have anymore questions feel free to ask.
>
> I just studied pointers, but I didn't yet know of the existence of
> malloc and realoc. Anyway, your code, as well as these functions man
> pages are now putting me in the right direction. Thanks for the help.
>
> And I want to be bold, and ask again, cause this is really important for
> me: Anyone know of any C mailing list? (pretty strange that I can't
> find one!!).
>
> Cheers
You can use gcc mailing lists. They are really helpful.
--
Don't go around saying the world owes you a living. The world owes you
nothing. It was here first.
-- Mark Twain
_______________________________________________
bna-linuxiran mailing list
[EMAIL PROTECTED]
http://mail.nongnu.org/mailman/listinfo/bna-linuxiran