943,860 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 1532
  • C RSS
Jul 23rd, 2008
0

error C2447: '{' : missing function header (old-style formal list?)

Expand Post »
I am trying to fix this "error C2447: '{' : missing function header (old-style formal list?)" i looked over the program and cant find anything wrong. Here is my program.
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include "simpio.h"
  4. #include "strlib.h"
  5. #include "random.h"
  6. using namespace std;
  7.  
  8. #define LowerLimit 0
  9. #define UpperLimit 200
  10. #define StepSize 20
  11.  
  12. double CelsiusToFahrenheit(double c);
  13.  
  14. int main()
  15. {
  16. int c;
  17.  
  18. printf("Fahrenheit Celsius");
  19. for (c = LowerLimit; c <= UpperLimit; c += StepSize)
  20. {
  21. printf("%3d %f\n", c, CelsiusToFahrenheit(c));
  22. }
  23. system("pause");
  24. }
  25.  
  26. double CelsiusToFahrenheit(double c);
  27. {
  28. return (9.0 / 5.0 * c + 32);
  29. }
Reputation Points: 10
Solved Threads: 0
Light Poster
plike922 is offline Offline
38 posts
since Jul 2008
Jul 23rd, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

...
double CelsiusToFahrenheit(double c);
...
int main()
{
...
}

double CelsiusToFahrenheit(double c) ; // <- remove the semicolon
{
	return (9.0 / 5.0 * c + 32);
}
Reputation Points: 1105
Solved Threads: 389
Posting Virtuoso
mitrmkar is offline Offline
1,714 posts
since Nov 2007
Jul 23rd, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

Thanks
Reputation Points: 10
Solved Threads: 0
Light Poster
plike922 is offline Offline
38 posts
since Jul 2008
Jul 23rd, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

Perhaps, you should have posted this question on a C++ form .

And few things which I saw in your code, which you might have to consider to correcting

C++ Syntax (Toggle Plain Text)
  1. #include <stdio.h>
  2. to
  3. #include <cstdio>

And main should return a value. Well, it’s already if you don’t specify it as well, under C99 it automatically assumes to be return 0. But it is always a good practice to place them explicitly.

C++ Syntax (Toggle Plain Text)
  1. system("PAUSE");
Using system function is not very portable. You might have to consider using some different function. Have a look this thread
http://www.daniweb.com/forums/thread90228.html

NOTE: I still wonder why do you consider including

C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. and
  3. using namespace std;
You are just mixing up languages. Did anybody guide you to do that??

ssharish
Reputation Points: 73
Solved Threads: 20
Posting Whiz in Training
ssharish2005 is offline Offline
253 posts
since Dec 2006
Jul 25th, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

I have the same problem again but with a different program, any suggestions.

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include "simpio.h"
  4. #include "strlib.h"
  5.  
  6. #define GCD();
  7.  
  8. int main()
  9. {
  10. int x, y, g;
  11.  
  12. printf("1st number = ");
  13. x = GetInteger();
  14.  
  15. printf("2nd number = ");
  16. y = GetInteger();
  17.  
  18. printf("The GCD of %d and %d is %d", x, y, g);
  19. }
  20.  
  21. int GCD(int x, int y)
  22. {
  23. int g;
  24.  
  25. g = x;
  26. while (x % g != 0 || y % g != 0)
  27. {
  28. g--;
  29. }
  30. return (g);
  31. }
Reputation Points: 10
Solved Threads: 0
Light Poster
plike922 is offline Offline
38 posts
since Jul 2008
Jul 25th, 2008
1

Re: error C2447: '{' : missing function header (old-style formal list?)

#define GCD();
Take of that semicolon from that statment. Macros donst need a semicolon. If your marco definiation are like too big then you might use a '\' to speak it up and concatenate.

But for you just the semicolon off.

ssharish
Reputation Points: 73
Solved Threads: 20
Posting Whiz in Training
ssharish2005 is offline Offline
253 posts
since Dec 2006
Jul 25th, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

That can't be it because i still have the same problem but get another one
Reputation Points: 10
Solved Threads: 0
Light Poster
plike922 is offline Offline
38 posts
since Jul 2008
Jul 25th, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

Well, i could see some other problem as well now with that code. Can you please post the error message please

ssharish
Reputation Points: 73
Solved Threads: 20
Posting Whiz in Training
ssharish2005 is offline Offline
253 posts
since Dec 2006
Jul 25th, 2008
0

Re: error C2447: '{' : missing function header (old-style formal list?)

I question whether you want to #define this function instead of just declaring it at the top. Try replacing


  1. #define GCD();

with this:

  1. int GCD(int x, int y);
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Quadratic Formula
Next Thread in C Forum Timeline: shortcut to a large number of nested if-else statements





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC