I have written a simple program in C. A program to input a String and display it along with the length.
#include<stdio.h>
int main()
{
char a[4];
printf("Enter the name : ");
gets(a);
printf("\nThe name enterd is : %s",a);
printf("\nLength of string is : %d",strlen(a));
getch();
return 0;
}
The program do not contain warning or error.
At run-time I entered the value " melwinsunny " as input. There was no error and the result displayed was :
Enter the name : melwinsunny
The name entered is : melwinsunny
length of string is : 11
Why is it so? I have declared the character array of length 4 ( char a[4] ). Please explain.
Does this mean the character array is dynamic?