Search

Sponsored Links

Meta

Categories

Archives

Recent Posts

RSS Feeds

22
Dec

Print In Reverse-Order

Related Blog Items

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 */#include 

int main(){      
  char ch;      
  if ( (ch=getchar()) != ?n? )   {            
    main();            
    printf("%c",ch);      
  }
}

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 */
[tags]Printing in reverse order,reverse order printing program,program that prints in reverse order][/tags]

Popularity: 10%

You need to log on to convert this article into PDF


Related Blog Items

No Comments

No comments yet.

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image