Code:
#include <stdio.h>
int main(void)
{
/* The three variables we are going to identify*/
int myint;
int mychar[2];
float myfloat ;
/*Identifies a number*/
printf("Enter a number: ");
scanf("%d", &myint);
/*Identifies a character*/
printf("Enter a character: ");
getchar();
scanf("%c", &mychar);
/* Identifies a float*/
printf("Enter a float: ");
scanf("%f", &myfloat);
printf("%d === %c === %f\n",myint,mychar,myfloat);
}
The problem happening while reading the char .Because usually scanf will read the input upto '\n'.so when you read the integer the '\n' will remain in the buffer.When you try to read a character that '\n' comes in to play .To avoid that we can use getchar() to take that '\n' character . then you can read the character using scanf .