Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Cin doesn't work in console but works correctly with terminal in OSX. (QT 5.8)
Forum Updated to NodeBB v4.3 + New Features

Cin doesn't work in console but works correctly with terminal in OSX. (QT 5.8)

Scheduled Pinned Locked Moved Unsolved C++ Gurus
12 Posts 6 Posters 12.3k Views 3 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #3

    Just for curiosity, could you add #include <string> and try:

    // enter the temperature in Celsius
    int celsius;
    string celsiusString;
    cout << "Enter the temperature in Celsius:";
    getline(cin,celsiusString);
    celsius = stoi(celsiusString);
    

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    0
    • SGaistS SGaist

      Hi and welcome to devnet,

      What do you mean by console ?

      I Offline
      I Offline
      itzalak2
      wrote on last edited by
      #4

      @SGaist

      With console I mean the application output of QT.
      As I said it shows the text "Enter the temperature in Celsius:" correctly but doesn't do nothing when I write a number and press enter key.

      jsulmJ 1 Reply Last reply
      0
      • I itzalak2

        @SGaist

        With console I mean the application output of QT.
        As I said it shows the text "Enter the temperature in Celsius:" correctly but doesn't do nothing when I write a number and press enter key.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #5

        @itzalak2 As far as I know you cannot enter there anything. Check the "Run in terminal" checkbox in Run settings of your project.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        4
        • I Offline
          I Offline
          itzalak2
          wrote on last edited by itzalak2
          #6

          Thanks to all. Definitively you can't input anything through the console so I have to use the terminal.

          One thing I find horrible is that when I run a simple app, QT launches the terminal but there is a very long message and I was asking if there is a way to avoid it.

          I attach a capture, there you can see what shows the terminal when is launched by QT.

          terminal
          https://ibb.co/n7yMbF

          jsulmJ 1 Reply Last reply
          0
          • I itzalak2

            Thanks to all. Definitively you can't input anything through the console so I have to use the terminal.

            One thing I find horrible is that when I run a simple app, QT launches the terminal but there is a very long message and I was asking if there is a way to avoid it.

            I attach a capture, there you can see what shows the terminal when is launched by QT.

            terminal
            https://ibb.co/n7yMbF

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @itzalak2 What is the problem with this message? It is just what QtCreator is doing in the terminal to start your app. It will not be there if you start your app manually.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • I Offline
              I Offline
              itzalak2
              wrote on last edited by itzalak2
              #8

              Yes, I know, but I would like not to show this loooooong message because it fills the 50% of the terminal screen. Is it possible to hide this message?

              Thanks for the help.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                Like @jsulm wrote, it won't appear if you run it from a normal terminal.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  icebergenergy
                  wrote on last edited by
                  #10

                  Hello! I have similar problem, I checked terminal and getting this error
                  Please advise how to fix:
                  :-1: error: cannot open output file release\writeToDat.exe: Permission denied

                  JonBJ 1 Reply Last reply
                  0
                  • I icebergenergy

                    Hello! I have similar problem, I checked terminal and getting this error
                    Please advise how to fix:
                    :-1: error: cannot open output file release\writeToDat.exe: Permission denied

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #11

                    @icebergenergy
                    Doesn't sound like anything related to this issue.
                    Assuming release\writeToDat.exe is your executable and the right path to it, have you looked to see whether you already have that executable running, perhaps left over from when you ran it outside of Creator? Use Task Manager to have a look at what processes are running. Restart your PC and see whether error has gone away.

                    1 Reply Last reply
                    2
                    • I Offline
                      I Offline
                      icebergenergy
                      wrote on last edited by
                      #12

                      yeah! Already solved. Thanks. I had run it without building

                      1 Reply Last reply
                      0

                      • Login

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