Hello, I'm trying to capture letters entered by user into an array using classes. Although I'm having some unknown difficult issues:
//main .cpp file.
int main()
{
char guess = 'a';
hangman game1;
game1.getbuffer(guess);
guess = 'b';
game1.getbuffer(guess);
return 0;
}
at the minute as you can see I'm using pre set values, to try and get it working right, although i'm 100% certain the problem doesnt lie here I thought I'd post it anyway.
Heres the implemenation of the function:
void hangman::getbuffer(char a)
{
//takes in the letters
int i;
for ( i= 0 ;i < 4 ; i++)
buffer[i] = a;
//spits out the letters
for (i= 0 ;i < 4 ; i++)
cout <<buffer[i];
}
<< moderator edit: fixed [code][/code] tags >>
The code works , but its the output i dont like, since it prints 4xa's and 4xb's , not 1 a and 1 b.
Thanks
John