Moving contents of an array to another array

Hi everyone,
I am basically going to be picking apart a c-string that contains words and putting ONLY the unique words in a 2D array of char, in such way that there will be 1 word per row in the 2D array. But how do you put the token (word) in one row of the two dimensional array?

this is what i have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
char str[101]="" ;    //This is the array where i am picking the words from
	
char twoDarray[101][16] = {}; //This is where the unique words of str are going
                          //to be placed, i unique word per row

while (!read.eof())
{
		
		read.getline(str,100,'\n');
		char *pch;
		pch = strtok (str, " , .");
		while (pch !=NULL)				
		{
			cout<<"token: "<<pch<<endl; 
			pch = strtok (NULL, " ,.");
			
			twoDarray[0][0]= pch; //*I know this part is wrong, how do you do this part??
                }
		
}


what i want to do is place the first
token from str in the first row of the twoDarray and then put second token in the next row, and so on.

Any help would be greatly appreciated.
Line 17 would be: strcpy(twoDarray[0], pch); // Take care that the length of pch is < 16! But I'm not sure if it actually is what you want. It's practically a 1d array with c-strings

But why not using std::string? They're way more convenient...
Thanks for the help, i was specified i could not use c++ string objects so i can't use std :: string
i tried strcpy () but when i printed out twoDarray[0] it had nothing in it
Topic archived. No new replies allowed.