I'm making a hangman game in the console right now but I've run into this problem and can't seem to figure out what to do (hey, cut me some slack I just started this stuff like a week or so ago and it's not like I study all day... I've got a life). I'm still not quite done with this program but I can probably finish the rest of it once I get this problem fixed
What I'm trying to do is to have it get the length of the word it chooses and then output that many blank spaces so that the user know's how many letters it is
At first I tried using "string word" instead of "char word[]" but it says something like "cannot return length of basic_string::", so now I'm using char. Now I get 4 errors (each one specific to one of the random words) that says:
error C2440: '=' : cannot convert from 'char [x]' to 'char [x]'
There is no context in which this conversion is possible
Can anyone fix this code for me so that it will work or tell me what to do to make it work? Here's the code
Oh yeah, and I'm using Visual C++ 6.0 Standard.Code:#include "stdafx.h" int main(int argc, char* argv[]) { cout<<"DOS Hangman"<<endl; //declare variables srand(GetTickCount()); int n = rand()%4; char word[] = {0}; //choose word switch (n) { case 1: word = "This"; break; case 2: word = "Is"; break; case 3: word = "Another"; break; default: word = "Test"; } //outputs blank spaces int len; len = strlen(word); for(int x=0; x==len; x++) { cout<<"_ "; } return 0; }
Thanks for your help