What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
char line[3];
fgets(line, 3, stdin);
printf("%d\n", strlen(line));
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char line[3];
fgets(line, 3, stdin);
printf("%d\n", strlen(line));
return 0;
}
A. 3
B. 1
C. Any length since line did not end with null character
D. Depends on the standard
Answer: Option B
Join The Discussion