actually, um... that still doesn't work. I get these errors. Is there any way to do this? It says it expects a constant expression. Here's the errors I get:
Code:
C:\Program Files\Microsoft Visual Studio\MyProjects\Hangman\Hangman.cpp(12) : error C2057: expected constant expression
C:\Program Files\Microsoft Visual Studio\MyProjects\Hangman\Hangman.cpp(12) : error C2466: cannot allocate an array of constant size 0
C:\Program Files\Microsoft Visual Studio\MyProjects\Hangman\Hangman.cpp(12) : error C2133: 'spaces' : unknown size
C:\Program Files\Microsoft Visual Studio\MyProjects\Hangman\Hangman.cpp(90) : error C2065: 'spaces' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Hangman\Hangman.cpp(90) : error C2109: subscript requires array or pointer type
Oh, and, BTW, here's the revised first part of hangman.cpp:
Code:
#include <iostream.h>
#include <string.h>
#include <windows.h>
#include "Hangman.h"
struct hangman hang;
void hangman()
{
hang.PickWord();
hang.length=strlen(hang.word);
char spaces[hang.length];
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(hang.word, "corndog");
break;
case 1:
strcpy(hang.word, "computer");
break;
case 2:
strcpy(hang.word, "telephone");
break;
case 3:
strcpy(hang.word, "electric");
break;
case 4:
strcpy(hang.word, "stereo");
break;
case 5:
strcpy(hang.word, "oreo");
break;
case 6:
strcpy(hang.word, "microphone");
break;
case 7:
strcpy(hang.word, "cat");
break;
case 8:
strcpy(hang.word, "moose");
break;
case 9:
strcpy(hang.word, "internet");
break;
case 10:
strcpy(hang.word, "cow");
break;
case 11:
strcpy(hang.word, "potato");
break;
case 12:
strcpy(hang.word, "card");
break;
case 13:
strcpy(hang.word, "oven");
break;
case 14:
strcpy(hang.word, "speakers");
break;
default:
strcpy(hang.word, "earthquake");
}
}