
-----------------------------------
flameZero
Tue May 30, 2006 8:17 am

names and char arrays
-----------------------------------
hey guys im making a game for my summative in programming. i need the player to choose a player class using numbers ( example: 1 = fighter,2=mage , etc) but then in my if statement, my character array to say the class name will not say the name. is says                                                                                                    " incompatible types in assignment of `const char[8]' to `char[20]'"
i set the char array to 20 because my largest class needs 20 spaces, but the others range from 4 to 12. 
How can i get the array to see that, whether or not the array is full, to fill the array to the maximum for the  player class size  and then fill the rest woth blanks?

-----------------------------------
md
Tue May 30, 2006 10:55 am


-----------------------------------
you are trying to copy arrays; which doesn't work. You'd need to use the string functions to copy from one buffer to the other (see string.h)

If this is C++ I'd recomend using the std::string class instead as it will keep you from having to deal with character arrays (which are really really prone to overflow and memory leaks).  and  are your friends ;)

-----------------------------------
wtd
Tue May 30, 2006 11:05 am


-----------------------------------
If this is C++ I'd recomend using the std::string class instead as it will keep you from having to deal with character arrays (which are really really prone to overflow and memory leaks).  and  are your friends ;)

If you want to use "stdio.h" in C++, then you want to include "cstdio".  :)

-----------------------------------
md
Tue May 30, 2006 12:28 pm


-----------------------------------
I was actually thinking more along the lines of  but what with it being early and all I wasn't quite thinking.

-----------------------------------
flameZero
Wed May 31, 2006 7:20 am


-----------------------------------
ok thanks alot for the help :D
