Waow, thanks for the fast answer !!!
>void main()
>void main is not correct, use
>int main ( void )
>instead.
I see void main() in a tutorial, and there is no warning about this with the compiler.
>char a$;
>The $ isn't a standard character for identifiers. It may work for you, but your code is not >portable.
Well, in fact, before to try C, I spent many years programming in Basic. Hence the $ for strings. May be I kept bad habits...
Your code work well but don't solve the problem.
If I add a scanf in the program :
Code:
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
int main ( void )
{
int yn = 'y',loc;
while ( tolower ( yn ) == 'y' ) {
printf ( "Enter a number\n" );
/* next come the unwanted behaviour*/
scanf("%d",&loc);
printf ( "Do more stuff? (y/n): " );
fflush ( stdout );
yn = getch();
printf ( "\n" );
}
return 0;
}
After a y keypress, a 'y' is displayed on the screen when processing the scanf command :
****Display****
Enter a number
123
Do more stuff? (y/n):
Enter a number
y_
***************
I don't want this display of 'y'. How can I do ?
All the best
Pierre