Thread: RE: [Dev-C++] array of strings
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Khalid El-K. <kha...@ho...> - 2003-03-31 00:31:31
|
where can i find information about a linked lists, i don't know about them *shy* thanx for the suggestion :-) Regards, Khalid AL-Kary >why not return them to a linked list rather than an array? > >-- >thanks, >reid _________________________________________________________________ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail |
|
From: Khalid El-K. <kha...@ho...> - 2003-03-31 00:54:54
|
Hi, in this URL: http://www-math.unice.fr/laboratoire/help/C/ctutor/node163.html#SECTION0014100000000000000000 I found information about linked lists, but i also found out that the number of list elements is determined within the preprocessor "#define RECORDS 5" so how can this be useful in my case, i want to determine that number while the function is running ... or is there a thing wrong ? Regards, Khalid Al-Kary >where can i find information about a linked lists, i don't know about them >*shy* > >thanx for the suggestion :-) > >Regards, >Khalid AL-Kary >>why not return them to a linked list rather than an array? >> >>-- >>thanks, >>reid > > >_________________________________________________________________ >Add photos to your e-mail with MSN 8. Get 2 months FREE*. >http://join.msn.com/?page=features/featuredemail > > > >------------------------------------------------------- >This SF.net email is sponsored by: >The Definitive IT and Networking Event. Be There! >NetWorld+Interop Las Vegas 2003 -- Register today! >http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus |
|
From: Reid T. <Rei...@at...> - 2003-03-31 01:40:10
|
this example could be used also, just do not define RECORDS as a fixed const value, define records as an int and programatically set it to whatever value you need for your program. It could be a value calculated within the program or a value that you collect via input from the applications user. -- thanks, reid -----Original Message----- From: Khalid El-Kary [mailto:kha...@ho...]=20 Sent: Sunday, March 30, 2003 7:55 PM To: Dev...@li... Subject: RE: [Dev-C++] array of strings Hi, in this URL: http://www-math.unice.fr/laboratoire/help/C/ctutor/node163.html#SECTION0 014100000000000000000 I found information about linked lists, but i also found out that the number=20 of list elements is determined within the preprocessor "#define RECORDS 5"=20 so how can this be useful in my case, i want to determine that number while=20 the function is running ... or is there a thing wrong ? Regards, Khalid Al-Kary >where can i find information about a linked lists, i don't know about=20 >them >*shy* > >thanx for the suggestion :-) > >Regards, >Khalid AL-Kary >>why not return them to a linked list rather than an array? >> >>-- >>thanks, >>reid > > >_________________________________________________________________ >Add photos to your e-mail with MSN 8. Get 2 months FREE*. >http://join.msn.com/?page=3Dfeatures/featuredemail > > > >------------------------------------------------------- >This SF.net email is sponsored by: >The Definitive IT and Networking Event. Be There! >NetWorld+Interop Las Vegas 2003 -- Register today! >http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.=20 http://join.msn.com/?page=3Dfeatures/virus ------------------------------------------------------- This SF.net email is sponsored by: The Definitive IT and Networking Event. Be There! NetWorld+Interop Las Vegas 2003 -- Register today! http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Khalid El-K. <kha...@ho...> - 2003-03-31 14:10:42
|
More than useful, thank you fellow :-)
>Here I send you an example of
>a string array resizing on-the-fly as you require...
>This possible solution is built with the
>"realloc( )" function as you indicated in
>your message.
>
>I hope this example illuminates your way toward
>a peaceful programming...Salam alecum!!.
>Ricardo.
>
>
>*******************PROGRAM*******************
>/* ALLOCATING AND REALLOCATING MEMORY */
>#include <stdio.h>
>#include <stdlib.h>
>
>int main()
>{
> char **p;
> int N,i;
>
> printf("Give me the initial array string dimension: ");
> scanf("%d", &N);
> fflush(stdin);
>
> /* As you want your initial array dimension is given
> by the user and it is allocated in this way */
>
> p= (char **)realloc(NULL,N*sizeof(char*));
> for(i=0; i<N ; i++)
> {
> /*strings of 10 char */
> p[i]= (char*)realloc(NULL,10*sizeof(char));
> printf("dame string %d: ",i);
> gets(p[i]);
> puts(p[i]);
> }
>
> /* if you need to store still more array strings
> you can reuse the reallocate function as follows */
>
> printf("Give me the new array string dimension: ");
> scanf("%d",&N);
> fflush(stdin);
>
> p= (char **)realloc(p,N*sizeof(char*));
> for(i=i; i<N ; i++)
> {
> p[i]= (char*)realloc(NULL,10*sizeof(char));
> printf("dame string %d: ",i);
> gets(p[i]);
> puts(p[i]);
> }
>
> /* Verification of correct string storing */
> printf("\n\n");
> for(i=0; i<N ; i++) puts(p[i]);
>
> /* At the end it is convenient to free the memory */
> for(i=0; i<N ; i++) free(p[i]);
> free(p);
>
> system("PAUSE");
> return 0;
>}
>
>*****************************
>
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
|