hi all,
I have a global array of char array like so
I then set initialise it with memsetCode:char *myArray[100];
Now the problem is that I have a function which is called multiple times which assigns strings the myArray like so (obviously this is a simplified version)Code:memset(myArray, '\0', sizeof(myArray));
Now the problem is that when I leave the myArrayAssignment function the variable "buf" becomes out of scope so the indexs of myArray all point to junk.Code:void myArrayAssignment(int i){ char buf[] = "hello world"; myArray[i] = buf; }
I will need to change myArray from
to the form of something like this:Code:char *myArray[100];
But i dont know how to assign to the array because C++ doesnt allow for array to array assignments.Code:char myArray[100][256];
Is there away to do this strcpy()?
Thanks