Examveda

What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
    char *str = "hello, world";
    char str1[9];
    strncpy(str1, str, 9);
    printf("%s %d", str1, strlen(str1));
}

A. hello, world 11

B. hello, wor 9

C. Undefined behaviour

D. Compilation error

Answer: Option C


This Question Belongs to C Program >> File Input Output

Join The Discussion

Related Questions on File Input Output