PDA

View Full Version : missing function header


truviet911
12-21-2008, 06:11 AM
I've been trying to learn c++ and this is my first prog. i have no idea where it went wrong it keep display this msg whenever i compile it.

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

im using visual studio 2008 by the way.

1 // Fig. 2.1: firstpro.cpp
2 // Text-printing program.
3 #include <iostream> // allows program to output data to the screen
4
5 // function main begins program execution
6 int main()
7 {
8 std::cout << "Welcome to C++!\n"; // display message
9
10 return 0; // indicate that program ended successfully
11
12 } // end function main

oracleguy
12-21-2008, 09:12 AM
Copy and paste the exact contents of your file, I ran that code without issue.

truviet911
12-21-2008, 08:30 PM
Copy and paste the exact contents of your file, I ran that code without issue.

i know when you run it without any problems. but when you build it it gives u problem. :D

oracleguy
12-21-2008, 10:34 PM
i know when you run it without any problems. but when you build it it gives u problem. :D

Well in order to run it, I had to build it. I compiled it just fine and ran the program and it worked correctly.

truviet911
12-22-2008, 02:46 AM
:DWell in order to run it, I had to build it. I compiled it just fine and ran the program and it worked correctly.

i found the solution for it already: you gotta add #include <stdafx.h> in the header . it required in visual studio 2008. thanks though