|
-
Nov 16th, 2000, 12:03 PM
#1
Thread Starter
Frenzied Member
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
-
Nov 16th, 2000, 12:18 PM
#2
Frenzied Member
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]
-
Nov 16th, 2000, 12:30 PM
#3
Thread Starter
Frenzied Member
-
Nov 16th, 2000, 05:49 PM
#4
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|