What will be the output of the following C code if 2 characters is typed by the user?
Posted: Wed Jul 13, 2022 7:54 pm
#include <stdio.h> #include <string.h> int main() { char line[3]; fgets(line, 3, stdin); printf("%d\n", line[2]); return 0; }
a) Compilation error
b) Undefined behaviour
c) 0
d) 10(ascii value of newline character)
a) Compilation error
b) Undefined behaviour
c) 0
d) 10(ascii value of newline character)