char array

hello,
so i have two char array
and basically i want to do this:
1
2
3
4
5
6
7
8
9
10
        char message[10]; 
	char word[10]; 
	 
	 message="arts"; 

	 word=message; 
	 
	 word="game"; 

	 cout<<word; 


if i set it to string then works but why doesn't it work for char array?
You may want to read a little more on this: http://cplusplus.com/doc/tutorial/ntcs/

with character arrays, things like:
 
   char message[10] = "arts";

are completely valid, but only if you are doing this in the initialization, and only if you are initializing it the moment it is being declared.

After that, assignments such as:
 
   message = "arts";


become invalid.


Unless you have a pretty good grasp on arrays and pointers, you're probably better off sticking with strings for now.
Last edited on
Thanks for the replay. I have to do this in char. Can anyone give me an example on how i would go about doing this.
strcpy and related functions.
In C/C++ there is no assignment operator for arrays. You have to use some sort of coping that to assign one array to another.
Topic archived. No new replies allowed.