Vamsi Pavan’s Place

When curiousity outbursts …..

default function prototype

October 6th, 2006 · No Comments · C/C++

When the compiler sees a new function (ex. show) about which it doesn’t know anything. It by default assumes the function to be returning int. But when compiler sees the actual definition of function (show), if mismatch occurs (might be because of other return type) error is generated.
main(){
show();
}
void show(){
printf(”I’m the greatest”);
}
The solutions are as follows:
1. declare void show() in main() .
2. define show() before main().
3. declare extern void show() before the use of show().

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

Tags:

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment