Monday 8 April 2013

char a[4]="HELL"; must check


    main()
{  
char a[4]="HELL";
printf("%s",a);
}
Answer:
         HELL%@!~@!@???@~~!
Explanation:
The character array has the memory just enough to hold the string “HELL” and doesnt have enough space to store the terminating null character. So it prints the HELL correctly and continues to print garbage values till it     accidentally comes across a NULL character.

Blog Author: Vijay Kumar

No comments:

Post a Comment