What will be the output of the following C code if 2 characters is typed by the user? [code] #include <stdio.h> #include <string.h>

Daniel William

New member
What will be the output of the following C code if 2 characters is typed by the user?
Code:
    #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)
 

Tìm kiếm

Back
Top