I’m having problems allocating memory for an array of strings. Here’s my code:
(char **val1 = NULL and char **val2 = NULL exist).
There seems to be a problem as to where the pointers are pointing in memory since val1 sometimes returns the content of val2. Thanks for any help in advanced.
This is an OpenGL forum, and not a forum for beginning ANSI C programming. Get a good ANSI C book and read up on how to use realloc and how strings are handled in C.
[This message has been edited by Asgard (edited 09-10-2002).]
I can see two mistakes in that code. First, sizeof(char) should rather be sizeof(char *) if I understand the purpose of the code right. Second, the tempval pointers are useless, assign to the val pointers directly.
Get a C or C++ language reference text. Read the section on pointers and arrays VERY CAREFULLY. Don’t start writing code until you understand those sections well.