suppose I have a double pointer that stores words in a list:
ex:
char **wordlist;
How do I store the data of **wordlist into a 2-dimensional array say List[define][define2] which is also a char?
Printable View
suppose I have a double pointer that stores words in a list:
ex:
char **wordlist;
How do I store the data of **wordlist into a 2-dimensional array say List[define][define2] which is also a char?
strcpy( list[x], wordlist[y] )
i think, check man page for strncpy to make it better
edit: youll need to put a loop in there too
You need to allocate lots of memory
Do this once
Code:/* allocate space for all the word pointers */
wordlist = malloc ( numberOfWords * sizeof *wordlist );
Do this for all the words you want to copy
Code:wordlist[i] = malloc ( strlen(myWord)+1 );
strcpy( wordlist[i], myWord );