Help :S

i'm new to visual c++

i used to use the free borland c++ 6 enterprise compiler, now i switched to visual since it was a free download
the problem is when you have to name the include files... in borland i just typed

#include <iostream>
#include <iomanip>
using namespace std;

main()

{

cout << "I WIN!!";

cin.get();

}

that would run perfectly fine in Borland but in Visual C++ i get these errors:

1>Compiling...

1>Probeersel1.cpp

1>.\Probeersel1.cpp(4) : error C2871: 'std' : a namespace with this name does not exist

1>.\Probeersel1.cpp(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>.\Probeersel1.cpp(8) : error C2065: 'cout' : undeclared identifier

1>.\Probeersel1.cpp(9) : error C2065: 'cin' : undeclared identifier

1>.\Probeersel1.cpp(9) : error C2228: left of '.get' must have class/struct/union

1> type is ''unknown-type''

I know it has something to do with the namespace std; and the include files but....
i just don't get how i have to type em :s


any help would be really appreciated



Answer this question

Help :S

  • Ravindra K Agrawal

    Good afternoon...

    Where do you get stdafx.h from   It's not part of the header files that come with Visual C++ Express   At least I can't find in the VC\include directory.  Thanks.

  • Phil Winder

    Hi,

     Tom_P wrote:

    1>.\Probeersel1.cpp(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int



    This message means a lot in MS world. Change [main()] function as follow;

    int main()
    {

    }

    Hope this helps.


  • jwennstrom

    I said in the previous post that ".. means a lot in MS world". This kind of wording should be avoided.  I am very sorry for that. My real intention is to make it clear that Microsoft is one of the companies that strongly support standard C++ rules. 

    See below;

    http://pluralsight.com/blogs/hsutter/archive/2005/09/22/14970.aspx



  • EdTacey

    Are you sure that this is the complete sourcecode

    Or does the sourcecode looks like this
    #include <iostream>
    #include <iomanip>

    #include <stdafx.h>


    In this case place your include files behing the stdafx.h

    Otherwiese I can not repro the problem on my machine.

  • Albert Valls Rovira

    The stdafx.h is usually created by the wizards for native programming (not part of Express). The precompiled headers are a feature that allow faster compiling for large projects.

    You can create the files by yourself. They behave like a normal include file. Only in the case you activate precompiled headers the compiler reads writes a precompiled header state file (pch file) with the contents of the compiled state including all files up to stdafx.h. So all files before stdafx.h are not included in the build and ignored. That was the reason for my post

  • Akin

    lol sorry for not checking any sooner... as i rememberd i posted another two times in this thread but for some reason they aren't showing up or sumthing

    i want to thank everyoen for their help ^^

    the compiler works real smooth now :D

  • Help :S