Array Indexing w/ strlen()
I'm designing a hangman game engine and I can't seem to get variably indexing to work with the strlen function. Is there anything I can do to get thsi to work? Here is the beginning part of my constructor file (Hangman.cpp... not like you care anyways)
Code:
struct hangman hang;
void hangman()
{
hang.PickWord();
hang.length=strlen(hang.word);
char spaces[10];
for(short x=0; x<hang.length; x++)
{
spaces[x]='_';
}
while(hang.loopvar!=false)
{
hang.BlankSpaces();
hang.Guess();
hang.Check();
}
}
void hangman::PickWord()
{
srand(GetTickCount());
short random=rand()%15;
switch(random)
{
case 0:
strcpy("corndog",hang.word);
break;
case 1:
strcpy("computer",hang.word);
break;
case 2:
strcpy("telephone",hang.word);
break;
case 3:
strcpy("electric",hang.word);
break;
case 4:
strcpy("stereo",hang.word);
break;
case 5:
strcpy("oreo",hang.word);
break;
case 6:
strcpy("microphone",hang.word);
break;
case 7:
strcpy("cat",hang.word);
break;
case 8:
strcpy("moose",hang.word);
break;
case 9:
strcpy("internet",hang.word);
break;
case 10:
strcpy("cow",hang.word);
break;
case 11:
strcpy("potato",hang.word);
break;
case 12:
strcpy("card",hang.word);
break;
case 13:
strcpy("oven",hang.word);
break;
case 14:
strcpy("speakers",hang.word);
break;
default:
strcpy("earthquake",hang.word);
}
}
And, uh... thanks in advance if you decide to help