Hello, I'm new here and to programming, but I want to know if it's possible to make a local variable into a global.
my program is a simple hangman with the possibility to enter your own secret word and guess each letter.
void drawing(int position);
void guessword(string word);
int strLangd(char str[]);
int main()
{
int number, k;
int count = 0;
int position;
string word;
char letter;
char secretword[41];
cout<<"type the secret word: ";
cin.getline(secretword, '\n');
k= strLangd(secretword);
system ("cls");
srand(time(NULL)); //initializes the random number generator
guessword(word, k);
cin.ignore(255,'\n');
cin.get();
return 0;
}
void guessword(string word,)
{
char letter;
int position;
int i=0;
here's part my program, what i want to do is make the variable 'k' into a global or at least, bring it to the "void guessword(string word)" function.k is supposed to count how many letters the secret word is. But everything i try either makes the program unable to run, or windows says that it found a problem with it and that it needs to close.
Any help to make this work would be great!
You need to modify your function prototype and header to guessword(string word, int k)
Also like Zeldami was saying use [code] tags to make your code more readable
I've tryed that as well, it allows me to enter the secret word and press enter, then windows shows up and says there's a problem and it needs to shut down... thanks for trying tho