By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Declaration syntax error

P: n/a
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. int stat()
  4. main()
  5. {
  6. int i;
  7. clrscr();
  8. for(i=1;i<=4;i++)
  9.     {
  10.     stat();
  11.     }
  12. }
  13. void stat()
  14.     {
  15.     static int x;
  16.     x=x+1;
  17.     printf("x = %d",x);
  18.     }
Nov 25 '10 #1
Share this Question
Share on Google+
4 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
You declare your stat() function to return an int but you code it to return void.
Nov 25 '10 #2

P: n/a
declare your int stat(); not like int stat()
second its int stat() not void stat()
Nov 25 '10 #3

P: 7
#include<stdio.h>
#include<conio.h>
int stat();
main()
{
int i;
clrscr();
for(i=1;i<=4;i++)
{
stat();
}
}
int stat()
{
static int x;
x=x+1;
printf("x = %d",x);
}
Nov 25 '10 #4

Expert 100+
P: 2,396
Please use code tags, they make it much easier to refer to specific lines of your code.

You define stat to return an int, but you allow execution to fall through to the closing brace. If the function has a return value then you must end the function with a return instruction that returns a value of the specified type.
Nov 26 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.