Hit <ENTER> to continue...

This is a discussion on Hit <ENTER> to continue... within the C Programming forums, part of the General Programming Boards category; Hi folks!I was wondering if anyone knows how can i make my program to wait for the user to press ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    4

    Hit <ENTER> to continue...

    Hi folks!I was wondering if anyone knows how can i make my program to wait for the user to press <ENTER> and then continue with the rest of the commands.In a Pascal program example:

    Code:
    ........................ 
    writeln("Hit <ENTER> when you are ready..."); 
    readln; 
    .....(rest of code).....
    Is there anyway to do the same thing in C?I tried with scanf() function but it doesnt work the way i want to.

    PS:I tried to use the system() function with a parameter like "sleep 2" which causes the program to pause for 2
    seconds(in a Unix system)-but as you probably understand,it isnt very convenient...

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    printf("Hit enter to continue...");
    getchar();

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 11-03-2008, 08:48 PM
  2. Continue and switch
    By camzio in forum C Programming
    Replies: 10
    Last Post: 10-04-2008, 08:31 AM
  3. Key hit interupt?
    By SwarfEye in forum C Programming
    Replies: 2
    Last Post: 09-26-2006, 12:02 AM
  4. switch - continue
    By DavidP in forum C Programming
    Replies: 2
    Last Post: 06-24-2004, 10:09 AM
  5. continue in while loops
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 03-04-2002, 09:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21