Trouble making simple program.

Hi I am trying to create a simple hello world program and its not working.

here is what i do


i create a empty project and name it "hello"

then I right click on the progect icon and go to ADD > Class > C++ > C++ Class
the window pops up and I enter the class name "HelloWorld" while I am doing this the ".h file:" and ".cpp file:" auto file with the same name and their own extentions. Thats all i do and then I click "Finish"

I right click on "hello" > ADD > New Item... > Code > C++ File (.cpp)

give it a name like "hello2"

enter the code
#include<isotream.h>
using namespace std;
int main()
{ cout<<"hello";
return(0);
}

I save the file

and then when I try to run it "F5"

I get this error


http://www.uri.edu/personal/mafd6225/1.JPG

http://www.uri.edu/personal/mafd6225/2.JPG

http://www.uri.edu/personal/mafd6225/3.JPG

can someone please help me








Answer this question

Trouble making simple program.

  • TilakGopi

    #include<iostream>

    int main()

    {

    std::cout<<"hello";

    return(0);

    }


    i did all i could and now im getting the same error



    here is the log



    1>------ Build started: Project: test3, Configuration: Debug Win32 ------

    1>Linking...

    1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup

    1>Debug\test3.exe : fatal error LNK1120: 1 unresolved externals

    1>Build log was saved at "file://c:\Documents and Settings\1\My Documents\Visual Studio 2005\Projects\test3\test3\Debug\BuildLog.htm"

    1>test3 - 2 error(s), 0 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




    someone said im making a windows application im not sure what that means im very new to this stuff can someone please please give me step by step instrutions how to make a c++ project
    like hello world.


  • Eduardo Martinez

    I'm going to assume you are using Visual C++ 2005 Beta-2

    Here are the steps I use:

    Open the IDE

    Click on File.New.Project

    Select Win32 Console Application and give it a name: say "Hello"

    Click OK and then click Finish

    Once the Solution Explorer appears vlick on the main source file: if you named the Solution "Hello" this file will be called hello.cpp. The source file should appear something like what is shown below:

    // First.cpp : Defines the entry point for the console application.
    //
    #include "stdafx.h"

    int _tmain(int argc, _TCHAR* argv[])
    {
        return 0;
    }

    Add the following source code to the _tmain function (don't worry that it is _tmain and not main).

    std::cout << "Hello World" << std::endl;

    Now open the stdafx.h file and add the following line

    #include <iostream>

    The build your project. It should build cleanly and you will then be able to execute the resulting application.



  • DrMicrochip

    This program is not valid. You got build errors, so no executable program was created. You need to fix the build errors.

    The include needs to be:
    #include <iostream>

    And the compiler error (in the output window) should have indicated you that the header "isotream.h"does not exist.

    Ronald Laeremans
    Visual C++ team

  • hypershot

    Thanks Mr. Caves,

    but now im running into a different problem when i executed the program, the output window comes and goes really fast, it does not say on. it like blinks on then it closes.

    how can i fix that          

  • PaulC1234

    Try setting a breakpoint in the main function: this should stop the execution and let you see what is happening.

  • ShaunWilks

    If you in fact built a console application as Mr. Caves suggested the console window is opening when you launch your application then closing the console window when the end of your application flow is reached.

    Something simple to pause your application while it is executing will leave the window open long enough for you to see the contents of the window.

    Try adding the following code inside your tmain just before the closing bracket. The last three lines of your tmain should be:

    // pause after executing console application
    fprintf( stdout, "\n\nHit any key to exit...\n");
    fgetchar();
    return 0;


  • Mark Panarusky

    The first message is because you have tried to run the program before you have compiled it.

    The second message is because the compilation failed and the project system is suggesting that you might want to execute the program which resulted from the last successful compilation.

    The third message is because there wasn't a previously successful compilation and so there is no program to execute.

    You should take a look at the build errors that were generated, fix them and then try to rebuild the program.

  • Trouble making simple program.