Hi current Jesús, i'm writing from the future. Now you think that you are clear about C, pointer, strings, etc. But i know you so well, and i know that in the future, you'll need this code to open your mind and remember what you knew in the past about pointers.
For example, when you want to declare a string in C, i usually do:
char* foo = "myString";
or i can do:
char foo[] = "myString";
Ok, but, what about lists of strings? I mean, if i want to declare a list of strings, i could do this:
char* foo[] = {"myString1", "myString2"};
But now i was in the tube coming back to home and i was thinking about how to do this with pointers (i know that it is simply but i'm excited because i'm learning C and i discover that my thoughts weren't so far from reality)
So, this is another way to do the same, but knowledge is free :)
char** foo = (char**) malloc(sizeof(char*)*numberOfStrings);
foo[0] = "myString1";
foo[1] = "myString2";
Thanks Jesús from the future!!!!!!! :D
domingo, 5 de diciembre de 2010
Suscribirse a:
Enviar comentarios (Atom)
I like this.
ResponderEliminarBarack Obama while reading a lil bit of WikiLeaks before going to bed.
j4k4n0 als0 l1k3s th1s