|
-
April 11th, 2010, 08:06 PM
#1
Console Adds A \n Automatically When Enter Is Pressed
Hello, just joined this forum (: sorry if this is posted but i have searched google everywhere and can not seem to resolve this problem. My program is a MasterMind game, where you have to guess 4 colours in the correct order and correct colour to win. Ill just post the one function im trying to fiddle with as it is quite long unless you want me to (:.
The Code:
void getGuess(char *guess, int n)
{
int valid;
int c;
cout << "\n";
for(c=0; c<n; c++)
{
do
{
cout << "Please Enter Guess " << c+1;
gotoxy(20,19);
cin >> (guess[c]);
guess[c] = toupper(guess[c]);
switch(guess[c])
{
case 'R':
case 'G':
case 'C':
case 'M':
case 'B':
case 'Y':
valid = 0;
break;
default:
valid = 1;
printf("Please Re-Enter either 'R' 'G' 'C' 'M' 'B' 'Y'"); break;
}
}while(valid !=0);
}
}
When i dont use the 'gotoxy(20,19);' the output is as follows:
Please Enter Guess 1
Please Enter Guess 2
Please Enter Guess 3
Please Enter Guess 4
So it goes on a new line each time i print it but i want the other lines to just replace the second line. So it looks like this:
Please Enter Guess 1: (When you put a colour and press enter it just replaces the '1' with a '2' etc.
When i have the 'gotoxy(20,19);' it does work kinda. It replaces the line but i have to have the cursor above the 'Please Enter Guess 1' so it looks like this.
***************** m
Please Enter Guess 1
Ignore the stars, they are just to move the 'm' or what ever colour is located.
Which isnt really what i want, i hope all that makes sense, thanks very much in advance (:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|