Help With getchar();

This is a discussion on Help With getchar(); within the C++ Programming forums, part of the General Programming Boards category; Hello, I need to know how to be able to press any button on the keyboard instead of pressing enter ...

  1. #1
    User
    Guest

    Help With getchar();

    Hello,

    I need to know how to be able to press any button on the keyboard instead of pressing enter like the following code?

    #include <stdio.h>
    #include <iostream.h>
    int main(){
    cout <<"Press Enter"<<endl;
    getchar();
    cout <<"Thank You"<<endl;
    return (0);
    }

    Thank Your For Your Help

  2. #2
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    kbhit();

    getch(); //might

    cin.get(char_type); // possibly
    Blue

  3. #3
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    Isn't that getchar() is like getch()?
    Yoshi

  4. #4
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    hm

    #include "iostream.h"
    #include "conio.h"

    int main()
    {
    cout << "Press a key" << endl;
    getche();
    cout << "Thank you." << endl;
    return (0);
    }

  5. #5
    Unregistered
    Guest
    >>>getche();

    get character and echo...

    or

    getch()

    get character no echo... In these cases, I prefer to not echo the character to the screen, but it has its uses


    >>Isn't that getchar() is like getch()?


    You tell me... compile the following.



    #include <iostream>
    #include <conio>
    using namespace std;

    int main()
    {

    cout << "Press any key and then enter to continue: ";
    getchar();

    cout << "Press any key to continue: ";
    getch();



    return 0;
    }

  6. #6
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    last post was me... damn logoffs
    Blue

  7. #7
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    also

    getche() and getch() work as described in the previous posts...
    And you can use ... lol (pointless, but still posting it)...

    #include "iostream.h"
    #include "stdlib.h"

    int main() {
    system("pause");
    cout << endl;
    return (0);
    }

  8. #8
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    system ("format C:") usually stops things pretty well too.

    ****Don't do this... it is a joke*******

    *****If you do... don't answer yes when it asks you if you are sure*****
    Blue

  9. #9
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    !!

    ROFL

  10. #10
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    Just do this::
    system("del *.*");

    But, please, don't do it. >

    about the getch() and getchar(), I was just kidding. Calm down.
    >:<
    <:>
    >:>
    <:<
    Yoshi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getchar() problem
    By jlharrison in forum C Programming
    Replies: 6
    Last Post: 01-25-2006, 02:49 PM
  2. getchar buffer size
    By oncemyway in forum C Programming
    Replies: 3
    Last Post: 08-02-2005, 01:49 AM
  3. getchar() problem from K&R book
    By anemicrose in forum C Programming
    Replies: 13
    Last Post: 04-05-2004, 12:06 AM
  4. help with getchar lol
    By Taco Grande in forum C Programming
    Replies: 5
    Last Post: 03-18-2003, 09:25 PM
  5. Can anybody take a look at this?
    By TerryBogard in forum C Programming
    Replies: 10
    Last Post: 11-21-2002, 01:11 PM

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