Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Invoke ENTER KEY

Invoke ENTER KEY

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 Posters 0 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.
  • M Offline
    M Offline
    manju 3
    wrote on last edited by
    #1

    Hi all, I am trying to run one console based application, Where i reading a argument from command line. If i press ENTER ,i am writing the sane to the command line. How can i print the same without pressing ENTER. Can i execute the second printf without pressing ENTER This is the code i am using

    int main(int argc, char* argv[])
    {
    int aNumber;
    char aChar;
    printf("\nEnter a number:");
    scanf("%d", &aNumber);
    printf("\nThe number entered is %d\n", aNumber);
    return 0;
    }

    Thanks Sharan

    I L S 3 Replies Last reply
    0
    • M manju 3

      Hi all, I am trying to run one console based application, Where i reading a argument from command line. If i press ENTER ,i am writing the sane to the command line. How can i print the same without pressing ENTER. Can i execute the second printf without pressing ENTER This is the code i am using

      int main(int argc, char* argv[])
      {
      int aNumber;
      char aChar;
      printf("\nEnter a number:");
      scanf("%d", &aNumber);
      printf("\nThe number entered is %d\n", aNumber);
      return 0;
      }

      Thanks Sharan

      I Offline
      I Offline
      Irwin R
      wrote on last edited by
      #2

      On Windows, you can utilise the _getch function, which is exposed by conio.h. On *nix, you can use tcsetattr to turn off canonical mode, which is exposed by termios.h, which'll offer immediate feedback when reading.

      1 Reply Last reply
      0
      • M manju 3

        Hi all, I am trying to run one console based application, Where i reading a argument from command line. If i press ENTER ,i am writing the sane to the command line. How can i print the same without pressing ENTER. Can i execute the second printf without pressing ENTER This is the code i am using

        int main(int argc, char* argv[])
        {
        int aNumber;
        char aChar;
        printf("\nEnter a number:");
        scanf("%d", &aNumber);
        printf("\nThe number entered is %d\n", aNumber);
        return 0;
        }

        Thanks Sharan

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi , Use this modified code. Modified code,

        #include
        int main(int argc, char* argv[])
        {
        int aNumber;
        char aChar;
        printf("\nEnter a number:");
        scanf("%d", &aNumber);
        printf("\nThe number entered is %d\n", aNumber);
        _ getch();_
        return 0;
        }

        1 Reply Last reply
        0
        • M manju 3

          Hi all, I am trying to run one console based application, Where i reading a argument from command line. If i press ENTER ,i am writing the sane to the command line. How can i print the same without pressing ENTER. Can i execute the second printf without pressing ENTER This is the code i am using

          int main(int argc, char* argv[])
          {
          int aNumber;
          char aChar;
          printf("\nEnter a number:");
          scanf("%d", &aNumber);
          printf("\nThe number entered is %d\n", aNumber);
          return 0;
          }

          Thanks Sharan

          S Offline
          S Offline
          Satheesh1546
          wrote on last edited by
          #4

          Hi, try to run this program from the windows command prompt..

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups