-
Hi,
I'm trying to learn VC++ and found an example excersice but it doesn't seem to work. Here is the code:
Code:
#include <iostream.h>
int main();
{
int x=5;
int y=7;
cout "\n";
cout << x + y << " " << x * y;
cout "\n";
return 0;
}
I get the following error when trying to compile the above .cpp file:
"error C2447: missing function header (old-style formal list?)"
Any ideas what this is and how to fix it?
Any help would be appreciated..
Dan
-
Don't put ; after main() also cout "\n" is wrong. Use cout<<"\n"
Code:
#include <iostream.h>
int main()
{
int x=5;
int y=7;
cout<< "\n";
cout << x + y << " " << x * y;
cout<< "\n";
return 0;
}
[Edited by Vlatko on 11-16-2000 at 12:22 PM]
-
-
Also, at the end of your program, you need to replace cout << "\n" with cout << endl.
What endl does is to add a newline, then flush the internal buffer. This ensures that all your data is displayed. However, it is slower so it should only be used every 20 lines or so.