Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem with cin in QCoreApplication

problem with cin in QCoreApplication

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    parvizwpf
    wrote on last edited by parvizwpf
    #1

    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?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      2
      • P Offline
        P Offline
        parvizwpf
        wrote on last edited by
        #3

        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

        mrjjM 1 Reply Last reply
        0
        • P parvizwpf

          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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved