Unwanted characters keep appearing
Consider the following program. Why is it that when the statement gets(str) is executed, the character pressed earlier automatically appears on the screen? Furthermore, is there a way to prevent this?
Code:
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
int main()
{
char str[50],choice;
choice=char(getch()); cout<<choice<<endl;
gets(str); getch();
return(0);
}
Compiler:Borland C++ 5.5
Re: Unwanted characters keep appearing
Quote:
Originally posted by sundeeptuteja
cout<<choice<<endl;
It seems to me you're printing it, so why shouldn't it show up?
If you mean something else, reply!