#include<stdio.h>
#include<conio.h>
void main()
{
char c;
int choice;
clrscr();
while(choice)
{
scanf("%c", &c);//Q.1>behaves weird as if newline is input for 'c', for second time
//onwards loop run.
//Q.2> But behaves ok, if a digit (0-9) is entered with
//scanf("%d", &c);
//Q.3> However, this modification eats up the display of
//value of 'choice' entered via keyboard.
//Q.4>Also, this change causes infinite loop if a non-digit is entered
//for 'c'.
printf("\n ascii code of %c is %d",c,c);
printf("\n Enter choice");
scanf("%d", &choice);
}
getch();
}
Any help that answers all 4 questions stated in comments above is highly welcome.Jiten
Edited by Alexander, 08 April 2011 - 07:04 AM.
Code blocks (# button)


Sign In
Create Account

Back to top









