Thread: First time using kbhit

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    7

    First time using kbhit

    I have no idea on how to do my program. What my should do is only let you type lower case letter and numbers, if you type caps it shouldn't show anything. If someone could help me out please?
    Here's the code:

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <ctype.h>
    
    
    main()
    {
     printf("type");
        if(kbhit(isupper))
        {
            goto out;
        }
        out:
        getch();
        return 0;
    }
    thanks
    Last edited by Brianop; 11-16-2013 at 06:24 PM.

  2. #2
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    Location
    astaylea
    Posts
    420
    Violence never solves anything. Try again when you're ready to use your keyboard properly.
    i dont believe in competition in da field of cboard posts, u see, i believe in a collection of posts each 2 be admired for der own personal statement. when in doubt, ask Willy!

  3. #3
    Registered User
    Join Date
    Oct 2013
    Posts
    7
    Quote Originally Posted by Barney McGrew View Post
    Violence never solves anything. Try again when you're ready to use your keyboard properly.
    sorry, im using translator English isn't my first language.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    isupper is a function; you have to pass a character into it. Presumably you want to get that character from kbhit somehow.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Indeed. kbhit() is a function that accepts no arguments, and returns a value. It certainly does not have a mode to tell it to return only uppercase letters. isupper(), on the other hand, accepts a single argument, and returns an indication of if that argument is uppercase. Logically, those two functions can be used together somehow.


    Note: kbhit() is also not standard C, but that's another story. There are ways to do what you want without using goto. Avoiding use of goto is often a good idea.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #6
    Registered User
    Join Date
    Oct 2013
    Posts
    7
    Quote Originally Posted by grumpy View Post
    Indeed. kbhit() is a function that accepts no arguments, and returns a value. It certainly does not have a mode to tell it to return only uppercase letters. isupper(), on the other hand, accepts a single argument, and returns an indication of if that argument is uppercase. Logically, those two functions can be used together somehow.


    Note: kbhit() is also not standard C, but that's another story. There are ways to do what you want without using goto. Avoiding use of goto is often a good idea.
    Thanks, you solved my problem. I didn't know that about kbhit

  7. #7
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    _kbhit

    this link has some code on it that should help you

    kbhit returns true when there is a input detected.
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. kbhit()
    By Rainer in forum C++ Programming
    Replies: 7
    Last Post: 08-04-2003, 08:10 PM
  2. kbhit()
    By McNab in forum C Programming
    Replies: 4
    Last Post: 04-30-2002, 06:57 PM
  3. need more help on kbhit()
    By lordvlaad() in forum C++ Programming
    Replies: 0
    Last Post: 04-20-2002, 02:07 AM
  4. kbhit
    By Kohatian 3279 in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2002, 05:04 PM
  5. kbhit()
    By wesentlich in forum Windows Programming
    Replies: 14
    Last Post: 03-26-2002, 01:09 PM