954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

static const int password=1705898;

int main;
{
		int secondnumber;
		while(true)

				cout>>("Enter Password")
				cin<<(secondnumber)

				if(password = Enter Password)

				cout<<"Welcome Lukus";
			else
				cout<<"Password Rejected";

system ("PAUSE")
return 0;
}

i am getting the error C2447: '{' : missing function header (old-style formal list?) error.
Can anyone tell me where i am going wrong to eliminate this error. thanks

Mark515
Newbie Poster
19 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

line 8: don't you see something a little strange about that line? hint: () and ;

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

i have also tried that line 8: int main () it did work and i have 1 failed with 75 errors :S

Mark515
Newbie Poster
19 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

>>int main ();
Of course not -- get rid of the semicolon!

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

yes i did im now getting 1 failed with 75 errors. :(

Mark515
Newbie Poster
19 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

You need to add { and } when there are more than 1 lines within while statements

while( <condition> )
{
   // some lines here
}
else
{
    // more lines here
}
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

static const int password=1705898;

int main()
{
		int secondnumber;
		while(true);
				}
				cout>> ("Enter Password")
				cin<< (secondnumber);
				{
				if(password = Enter Password)

				cout<<"Welcome Lukus";
}
			else
				cout<<"Password Rejected";
				{
system ("PAUSE")
return 0;
}


errors:

line (10) : warning C4101: 'secondnumber' : unreferenced local variable
"(13) : error C2143: syntax error : missing ';' before '>>'
(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(15) : error C2447: '{' : missing function header (old-style formal list?)
(20) : error C2059: syntax error : 'else'
(22) : error C2447: '{' : missing function header (old-style formal list?)

Mark515
Newbie Poster
19 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

braces are still wrong -- they are backwards and the closing } is on the wrong place. Re-read my previous post again. You need to count the number of opening and closing braces and make sure there is a } for every { (and vice versa)

line 11: delete the semicolon at the end of that while statement

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This is how to format the code. I also change a couple of other errors -- you had << and >> reversed. cout uses << and cin uses >>, you have them backwards.

>>if(password == Enter Password)
That is also wrong but I don't know how you need to correct it.


Help with Code Tags (Toggle Plain Text)

int main()
{
    int secondnumber;
    while(true)
    {
           cout << "Enter Password";
          cin >> secondnumber;
          if(password == Enter Password)
          {
               cout<<"Welcome Lukus";
          }
          else
          {
               cout<<"Password Rejected";
         }
}
system ("PAUSE")
return 0;
}
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

>>if(password == Enter Password)

Should be testing for secondnumber
if(password == secondnumber)

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You