C Programming - Print In Reverse-Order

This is only for printing, we are not storing the reversed output anywhere and another shortcoming is that it will cause SEGFAULT for a huge length string.

Recursive main() calling!! For beginners it will be a great to surprise to call main() function within main() it, but wait, Isn't main() also a function?

/* reverse.c */

int main()
char ch;
if ( (ch=getchar()) != '\n' ) {
}/* EOF */

Is it necessary to have a main() function for success full compilation (there is no function main() written anywhere in any of our translation unit)

No, We can write a variable named main, and that is enough for the compilation phase to succeed.

/* withoutmain.c */
int main;
/* EOF */


About this entry