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

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2007
Posts: 3
Reputation: RichardNero is an unknown quantity at this point 
Solved Threads: 0
RichardNero RichardNero is offline Offline
Newbie Poster

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

 
0
  #1
Nov 16th, 2007
i keep getting this error (error C2447: '{' : missing function header (old-style formal list?)
can someone give me a hint or help me out, I went from 23 errors to 1.
  1. // Enter a grade which is 1 and 100 for user.
  2. #include <iostream>
  3. using std::cin;
  4. using std::cout;
  5. using std::endl;
  6. using std::cerr;
  7.  
  8. #include <cstdlib>
  9. using std::rand;
  10.  
  11. #include <ctime>
  12.  
  13. void grade();
  14.  
  15. bool isCorrect( int, int ); // function
  16.  
  17. int main();
  18. {
  19. // srand( time( 0 ) ); // seed random number generator
  20. grade(void);
  21.  
  22. return 0; // termination
  23.  
  24. } // end main
  25.  
  26. // grade generates numbers between 1 and 100
  27. // and checks grade
  28. void grade()
  29. {
  30. int answer; // randomly generated number
  31. int guess; // grade entered
  32. char response; // 'y' or 'n'
  33.  
  34. do{
  35. // generate random number between 1 and 100
  36. // 1 is shift, 100 is scaling factor
  37. answer = 1 + rand() % 100;
  38.  
  39. // prompt for grade
  40. cout << "Enter number between 1 and 100.\n"
  41. << "Enter Grade?\n" << endl << "? ";
  42.  
  43. cin >> guess;
  44.  
  45. // loop until correct number
  46. while ( !isCorrect( guess, answer ) )
  47. cin >> guess;
  48.  
  49. // prompt for another grade
  50. cout << "\nExcellent! The grade is !\n"
  51. << "Would you like to enter a grade again (y or n)? ";
  52. cin >> response;
  53.  
  54. cout << endl;
  55. } while ( response == 'y' );
  56. }// end function grade
  57.  
  58. // isCorrect returns true if g equals a
  59. // if g does not equal a, displays hint
  60. bool isCorrect( int g, int a )
  61. {
  62. // grade is correct
  63. if ( g == a )
  64. return true;
  65.  
  66. // grade is incorrect; display hint
  67. if ( g < a )
  68. cout << "Grade is to low. Try again.\n? ";
  69. else
  70. cout << "Grade is to high. Try again.\n? ";
  71.  
  72. return false;
  73. } // end function isCorrect
Last edited by Ancient Dragon; Nov 16th, 2007 at 6:24 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 1,859
Reputation: twomers has a spectacular aura about twomers has a spectacular aura about twomers has a spectacular aura about 
Solved Threads: 55
twomers's Avatar
twomers twomers is online now Online
Posting Virtuoso

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

 
0
  #2
Nov 16th, 2007
You're right. Why bother using code tags.

>> int main();
>> {

Should be

>> int main()
>> {

No ; after main.
I blag!?
"Mr Kitty, you have to live in the attic now. Here, write a diary."
I am the Walrus!
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 3
Reputation: RichardNero is an unknown quantity at this point 
Solved Threads: 0
RichardNero RichardNero is offline Offline
Newbie Poster

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

 
0
  #3
Nov 16th, 2007
still get error,
Now that I have no hair......
is there anything else...
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

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

 
0
  #4
Nov 16th, 2007
> grade(void); It's just
grade();
Next time, use the [code][/code] tags. Between joining the forum and posting your first message there are many opportunities to learn how to do this, and you failed all of them.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC