What will be the output of the following C code considering user typed jkl?
#include <stdio.h>
int main()
{
char n[20];
fgets(n, 19, stdin);
ungetc(n[0], stdin);
printf("%s\n", n);
return 0;
}
#include <stdio.h>
int main()
{
char n[20];
fgets(n, 19, stdin);
ungetc(n[0], stdin);
printf("%s\n", n);
return 0;
}A. jkl
B. kl
C. Undefined behaviour
D. jk
Answer: Option A

Join The Discussion