Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

C++ Code Error : Missing Function Header

c++ Code Error Missing Function Header Programming header

  • Please log in to reply
2 replies to this topic

#1 Alcamech

Alcamech

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 181 posts
  • Location:In the pursuit of happiness
  • Programming Language:Python
  • Learning:C, Java, C++, C#, Python, JavaScript

Posted 16 July 2012 - 07:57 PM

I was writing some code to create Score Rater program and stumbled upon a error . It says that the bracket below my " int main(); " and the bracket below my " return 0; " and the " return 0; " itself requires a declaration . And I get a error when I try to build a solution that says " error C2447: '{' : missing function header (old-style formal list?) ". I dont understand what is casuing this issue . Can anyone help me fix this problem ?

Here is my code:


#include <iostream>
using namespace std;

int main();
{
int score;
cout<<"Enter your score: ";
cin >> score;

if (score >= 1000)
{
cout <<"You scored 1000 or more. Impressive!\n";
}
else if (score >= 500)
{
cout <<"You scored 500 or more. Nice.\n";
}
else if (score >= 250)
{
cout <<"You scored 250 or more. Decent.\n";
}
else
{
cout <<"You scored less than 250. Nothing to brag about.\n";
}

return 0;

}
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 16 July 2012 - 10:21 PM

You should not have the semicolon after the main -- look what you write
int main();

{

}
, but it must be
int main()

{

}

  • 1

#3 Alcamech

Alcamech

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 181 posts
  • Location:In the pursuit of happiness
  • Programming Language:Python
  • Learning:C, Java, C++, C#, Python, JavaScript

Posted 17 July 2012 - 06:29 AM

Thank you Kernelcoder
  • 0





Also tagged with one or more of these keywords: c++, Code, Error, Missing Function Header, Programming, header

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download