944,098 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1875
  • C++ RSS
Nov 16th, 2007
0

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

Expand Post »
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.
c++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RichardNero is offline Offline
3 posts
since Oct 2007
Nov 16th, 2007
0

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

You're right. Why bother using code tags.

>> int main();
>> {

Should be

>> int main()
>> {

No ; after main.
Reputation Points: 453
Solved Threads: 57
Posting Virtuoso
twomers is offline Offline
1,873 posts
since May 2007
Nov 16th, 2007
0

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

still get error,
Now that I have no hair......
is there anything else...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RichardNero is offline Offline
3 posts
since Oct 2007
Nov 16th, 2007
0

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

> 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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

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: Basic C++ Timer
Next Thread in C++ Forum Timeline: Urgent help in this code plz





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


Follow us on Twitter


© 2011 DaniWeb® LLC