When I don't include white space between %d
and %c
specification in the format string of scanf()
function in the following program, and give input during run-time as "4 h", then the output is "Integer = 4 and Character= .
How exactly variable "c"
takes the input in this case and what difference does it make if i include a white space between %d
and %c
specification ?
Code
#include <stdio.h>
int main()
{
char c;
int i;
printf("Enter an Integer and a character:\n");
scanf("%d %c",&i,&c);
printf("Integer = %d and Character = %c\n",i,c);
getch();
}