Whenever we store data more than the memory allocated to variable we got some unexpected results.But I declare a character array (name) with size 5 and get value from the user (greater than 5 characters).When i try to print it, I got the same exact output.Here is my program and its output.
char name[5] ;
printf("Enter Name:");
scanf("%s",name);
printf("Name = %snSize = %lu ",name,sizeof(name)/sizeof(char) ) ;
enter image description here
How this happened ?
2