How do use conventional C++ Code with Visual C++

Goodday


I cannot seem to create any programs with Visual C++ I am not getting anywhere the only program that works is Hello World:

#include <iostream>
using namespace std;
int main()
{
cout<< "Hello World\n";
return 0;
}

Not even the test win32 application want to run and i did everything like you explained


Please Help

Peder



Answer this question

How do use conventional C++ Code with Visual C++

  • jmargey

    Well, this looks like fine C++ to me, although I notice you're not including stdafx.h, are you not using precompiled headers ( the default is to use them )

    Either way, I recommend reading the 'how to ask questions' sticky post for guidance on how to ask questions that people can answer. In this case you've posted a valid C++ program, and no details on the errors which would tell us if you're using the wrong compiler ( it's happened ), the wrong project type, or what your error happens to be. Please post error info, and then we can help more.



  • allez

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=14021&SiteID=1

    BTW, I typed the error message into google and got a ton of hits. That's generally a good way to work out this sort of stuff. You've created the wrong sort of project.



  • threna

    Sorry Marius


    I get a compiler error.

    It give me a different error now i just fixed the libraries but its just like microsoft said it must be.

    It now says this with the Input/Output: MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup


  • Andreas Johansson

    This is a Simple program for input/output

    What is wrong with it


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

    int main()
    {
    string firstName;
    string lastName;
    int ID;

    cout << "Enter your first name ";
    cin >> firstName;

    cout << "Enter your last name ";
    cin >> lastName;

    cout << "Enter your ID number ";
    cin >> ID;

    cout << "Hello " << firstName << " " << lastName;
    cout << " or should I say " << ID << endl;

    return 0;
    }


    It gives me an error

  • opop

    And what kind of error do you get Compiler error Run-time error Can you post it here

  • spyork

    Really Because for other hundreds of thousand of programmers it works.

    So, can you explained what you tried to do and what exactly doesn't work



  • ChrisNewmanUK

    Obviuosly you told the linker that you want to create a Windows program (so one with a graphical interface), not a console programm.

    Check your project settings.



  • Bender

    Thanks Martin that was my problem


  • Rob Reiss

    Ok


    Sorry

    It Gives me this error if i use the above mentioned code : LINK : fatal error LNK1104: cannot open file 'user32.lib'.




  • How do use conventional C++ Code with Visual C++