0

Quick note : sorry about this beginners' question I am getting started in C++ and in programming in general. This is my whole code and I don't know why but, when I run it, it opens and closes in 1 frame but I'd like it to be running non-stop without debbuging until I close the program :

// This is my first C++ program !
#include <iostream>
using namespace std;

    int main()
    { 

        int x = 0;
        int cars = 14;
        int debt = -1000;
        float cash = 2.32f;
        double credit = 32.32;
        char a = 'a';
        char* sandwhich = "ham";
        bool does_I_like_ice_scream = true;
        auto do_I_have_a_good_cat = false;
        auto blank_check = 200.00;
        int over_9000 = INT_MAX;

        cout << over_9000 << endl;

        return 0;

    }

Thanks ! :D

Tech
  • 11
  • 1
  • 4
  • Hey sorry I'm kinda lost in this website so if you could give me a link that would help and I'll re-do the site tour eventually ! :D – Tech Nov 12 '17 at 21:35
  • Sure thing! :) Your question has already answers on two very popular questions, which ask the same thing as you did (a duplicate). You can find the links in the yellow box above your question. – Rakete1111 Nov 12 '17 at 21:38
  • I looked at the yellow box and nothing like my question ! :/ – Tech Nov 12 '17 at 22:01
  • Really? I understood your question is asking to make the program not close immediately when started. Can you explain it to me please? What am I missing? – Rakete1111 Nov 12 '17 at 22:04
  • Yeah what I want is the program running and not closing immediatly what can I do to fix that (sorry I'm confused af about our conversation) ^^ – Tech Nov 12 '17 at 22:11
  • Huh? So I understood you correctly? Did you try Ctrl + F5? Confused sorry – Rakete1111 Nov 12 '17 at 22:12
  • You understood. I did CTRL F5 just runs the program and then closes. – Tech Nov 12 '17 at 22:15
  • Aha, so that didn't help. How about `std::cin.ignore();`? – Rakete1111 Nov 12 '17 at 22:16
  • Omg ! Thanks ! That worked can you explain it thought :D ? – Tech Nov 12 '17 at 22:26
  • It ignores characters (in this case 1 because you called it without the first argument), but if there are no characters, it will wait until it gets some. If you use `std::cin` anywhere, be careful, as there will be a stray newline character on the steam, and so the ignore call will not wait. You will have to just increase the number :) (have a look at `std::numeric_limits` to ignore the maximum amount of characters) – Rakete1111 Nov 12 '17 at 22:56
  • Alrigth thanks so much !^^ sorry bout' the confusion – Tech Nov 12 '17 at 22:57

0 Answers0