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?
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
"Assumptions are the mother of all **** ups!"
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 );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.