Thread: input (could be easy)

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    16

    input (could be easy)

    I read somewhere that I could stop the user from effectively filling up a buffer and doing stuff before it appears on the screen. Such as say repeatily hitting the y button and having it go through a menu before they can see it. I would like to know how to do this without making them type anything extra to get out of it.
    "Practice means good, Perfect Practice means Perfect"

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Could you explain that a little better? Do you mean:

    1) Process user input before the enter key is pressed?
    2) Prevent user from overwriting your buffer?
    3) Something else?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    16
    I have this small program, and in it I call several getch()'s and I have a couple delays so the screen doesnt update instantly. However, I want to stop the user from inputing anything before they have a chance to read the screen.
    "Practice means good, Perfect Practice means Perfect"

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I don't know. I have only been programming for a few months now, but my intuition tells me that there is no standard way to do this but that it is possible if not in a roundabout way.

    Hmm, try this:

    // do screeen stuff...meanwhile user is busy filling up the buffer

    //screen appears

    fflush(stdin);

    //Now scan in user input with gets(), scanf(), or whatever...

    I am pretty sure that will work, now that I think about it...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    16

    uh...

    Well it isnt exactly working the way i want it to, as in it is doing nothing, and the compiler is accepting it. does it consider stdin to be a file?
    "Practice means good, Perfect Practice means Perfect"

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Didn't you want it to ignore user input till after they view the screen? Post your code and I will play with it...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Going to bed... will check in the morning...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #8
    Registered User
    Join Date
    Aug 2001
    Posts
    16
    I'd rather not post my code to the board, perhaps you could give me your email address, I can send it there, its about 30kb... although im going to bed right now too, so ill see you in the morning.
    "Practice means good, Perfect Practice means Perfect"

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    FYI: If you look at the bottom of most members posts, you will see a button labeled e-mail...also you can send the code as an attachment in your post....

    My e-mail is [email protected]
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  10. #10
    Registered User
    Join Date
    Aug 2001
    Posts
    16
    After years of surfing the internet there are certain things I automatically ignore, those buttons just happened to be one of them. I hardly see advertisements anymore just because I've encountered almost every type there are. Although, now I do see those buttons, and ill be sending the file as soon as possible.
    "Practice means good, Perfect Practice means Perfect"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input redirection
    By sashaKap in forum C Programming
    Replies: 6
    Last Post: 06-25-2009, 01:59 AM
  2. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 01:22 AM
  3. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  4. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  5. Help with Input Checking
    By Derek in forum C Programming
    Replies: 7
    Last Post: 06-17-2003, 03:07 AM