missing function header

Hi im very new to programing and i'v spent some time trying to write this, to store and display the string 'a dragon'. I keep on getting:
error C2447: '{' : missing function header (old-style formal list?)

i dont understand what i did wrong
whats missing?

#include<iostream>
#include<string>
int main(void);
{
using std::cout;
using std::string;
string yell
="a dragon\n";
cout<<yell.c_str<<"\n";
return 0;
}


1
2
3
4
int main(void); // get rid of this semicolon
{
  //...
}


Also you don't need 'void' in the parameter list. That's a goofy C thing.

It should be this:

1
2
3
4
int main()
{
  // ...
}



EDIT:

also, c_str is a function, so you need to call it. You call functions with parenthesis:

 
cout << yell.c_str() << "\n";
Last edited on
Got it, thank you
Topic archived. No new replies allowed.