problem with cin in QCoreApplication



  • i use this code:

    #include <string>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        int oo=0;
        cout <<"enter : ";
        cin>> oo;
    
        cout << " item : "<<oo;
    
        return a.exec();
    }
    
    

    when i run it will execute in output window and write enter:
    but when i type an integer and press enter it will repeat without end.
    question 1: how can i run this program in console window?
    question 2: why cin not work?


  • Qt Champions 2016

    Hi
    Try to run app "in terminal"
    in the Projects tab, under Run Settings, check the box marked "Run in Terminal".
    alt text



  • it is excited. because run in terminal is active by default . but i recheck it and it will run in terminal and cin works good.
    thanks


  • Qt Champions 2016

    @parvizwpf
    Yep, seen that too. Its the power of Flip Flop ;)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.