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
Forum Updated to NodeBB v4.3 + New Features

problem with cin in QCoreApplication

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.1k 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 8 Jan 2018, 19:03 last edited by parvizwpf 1 Aug 2018, 19:04
    #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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 8 Jan 2018, 19:29 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 8 Jan 2018, 19:36 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

        M 1 Reply Last reply 8 Jan 2018, 19:41
        0
        • P parvizwpf
          8 Jan 2018, 19:36

          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

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 8 Jan 2018, 19:41 last edited by
          #4

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

          1 Reply Last reply
          1

          1/4

          8 Jan 2018, 19:03

          • Login

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