Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Console is being automatticly closed after running

SchwarzeneggerSchwarzenegger Posts: 10Member
Dear programmers!

My problam is this: I am working with visual studio 2005, on c++ enviorement. When I try to compile a project (even the simplest one like: "cout << "hello" << endl;"), The DOS window is being opend and closed in less then a second!! This never happend to me when I was working on 2003, although i've heard several of my friends who've expirienced the same problem on 2003.
Now, I would expect it to remain open with the massage " Hello. Press any key to continue", but alas, it just doesnt.
It has come to my attention that there is a setting need to be alterd in order to solve this small dilema... Does anyone know how???

Sincerly yours,

Rotem Orbach.

Comments

  • tsagldtsagld Posts: 621Member
    : Dear programmers!
    :
    : My problam is this: I am working with visual studio 2005, on c++ enviorement. When I try to compile a project (even the simplest one like: "cout << "hello" << endl;"), The DOS window is being opend and closed in less then a second!! This never happend to me when I was working on 2003, although i've heard several of my friends who've expirienced the same problem on 2003.
    : Now, I would expect it to remain open with the massage " Hello. Press any key to continue", but alas, it just doesnt.
    : It has come to my attention that there is a setting need to be alterd in order to solve this small dilema... Does anyone know how???
    :
    : Sincerly yours,
    :
    : Rotem Orbach.

    End your code with "Console.ReadLine();". That causes your code to wait for input.


    Greets,
    Eric Goldstein
    http://www.gvh-maatwerk.nl


  • DonotaloDonotalo Posts: 715Member
    : Dear programmers!
    :
    : My problam is this: I am working with visual studio 2005, on c++ enviorement. When I try to compile a project (even the simplest one like: "cout << "hello" << endl;"), The DOS window is being opend and closed in less then a second!! This never happend to me when I was working on 2003, although i've heard several of my friends who've expirienced the same problem on 2003.
    : Now, I would expect it to remain open with the massage " Hello. Press any key to continue", but alas, it just doesnt.
    : It has come to my attention that there is a setting need to be alterd in order to solve this small dilema... Does anyone know how???
    :
    : Sincerly yours,
    :
    : Rotem Orbach.
    :
    [purple]
    i dont know about the settings, but u can use the statement [blue]system("PAUSE");[/blue] just before main() returns;
    [/purple]
    [hr][purple]~Donotalo()[/purple]

  • sobanksobank Posts: 25Member
    my solution is i think the oldest one on the block. :)

    void main(){
    cout<<"Hello"<<endl;

    getchar();//this line holds the program until u hit any key.

    }

  • HK_MP5KPDWHK_MP5KPDW Posts: 770Member ✭✭✭
    : Dear programmers!
    :
    : My problam is this: I am working with visual studio 2005, on c++ enviorement. When I try to compile a project (even the simplest one like: "cout << "hello" << endl;"), The DOS window is being opend and closed in less then a second!! This never happend to me when I was working on 2003, although i've heard several of my friends who've expirienced the same problem on 2003.
    : Now, I would expect it to remain open with the massage " Hello. Press any key to continue", but alas, it just doesnt.
    : It has come to my attention that there is a setting need to be alterd in order to solve this small dilema... Does anyone know how???
    :
    : Sincerly yours,
    :
    : Rotem Orbach.
    :

    [blue]You can add a [italic]cin.get()[/italic] statement or two to the end of your program.[/blue]

Sign In or Register to comment.