Wednesday, 6 August 2014

Find the output of the program.


           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.

No comments:

Post a Comment