Tuesday, August 9, 2011

Coding Puzzle No. 5?

#include<stdio.h>

void main()
{
         char s[]="four";
         printf("%d\n",puts(s));
}




Output:
four
5


ConCept:
Compare it with No. 4. Puts works differently, it  prints the string and goto the next line. But why it is returning 5, because it's capable of printing the '\0'. Hope you know that every string is succeeded by '\0' in C. 



No comments:

Post a Comment