Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

very basic dev-c++ question

  • 13-11-2005 11:49PM
    #1
    Closed Accounts Posts: 1,299 ✭✭✭


    Ok I am used to using sub etha edit on macs, yet when I try to use dc++ some of my programmes just suddenly close,

    this is a stupid example which does work


    //?//
    #include <iostream>
    using namespace std;

    int main (){
    double a,b,c,e,f,g,h,i;

    cout << "Enter a value for a ";
    cin >> a;
    cout << " Enter a value for b ";
    cin >>b;
    cout << "Enter a value for c ";
    cin >>c;
    e= + a + b +c;
    cout << "The value of " << e << "is" << endl;
    cin >> f;
    cout << f;
    cin >> g;
    h=(2*45*34*a)-(b*c*e);
    cout <<h;
    cin >> i;
    return 0;
    };


    the problem is that whenever i make a cout <<
    line and dont follow it up with c cin >> line
    the programme closes, it is as if everytime I write a cout it must be asking for a value


    Any ideas,

    sorry if this is obvious/unclear.


Comments

  • Registered Users, Registered Users 2 Posts: 2,002 ✭✭✭bringitdown


    Well cin will block awaiting input so the program will stop executing and await a 'user' to input something.

    If you have no blocking statements in your program, for example if you have:
    #include <iostream>
    using namespace std;
    
    int main (){
    
    cout << "This program will close immediately";
    
    return 0;
    };
    

    The program will execute the whole way through and close. To see output from such a program run it in a console / command-prompt (Mac OS X has one, previous versions?)


  • Closed Accounts Posts: 1,299 ✭✭✭Sandals


    ok great, that is what I am talking about, but can I get a console for windoes, where?


  • Registered Users, Registered Users 2 Posts: 2,002 ✭✭✭bringitdown


    For windows, the command line interpreter will do

    Start->Run->command
    OR
    Start->Run->cmd

    You will have to navigate to the directory your application / binary is in using DOS commands:

    cd c:
    cd SomeDir
    etc
    etc


  • Closed Accounts Posts: 7 Noogop


    just add the line

    system("PAUSE");

    before your return 0;
    it will make the program output the line
    "Press any key to continue . . ."
    before closing, you just hit return to end the program


  • Closed Accounts Posts: 1,299 ✭✭✭Sandals


    Ok thanks noogop, so much that is perfect I really apreciate it , all the other advice was lame and did'nt work.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,002 ✭✭✭bringitdown


    All the other advice ... last time you get jack from me.

    I explained the problem and gave you pointers on how to solve it, noogop gave you 'an' answer, one I wouldn't agree with but anyhoo on your merry way.


Advertisement