#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Check a part of string while user enters input - C


    I am trying to write a program where I need to check when a sequence of character is pressed while taking the input from user at the run time. I am not sure how to do that. for example, my sequence of character (keyword): 1011

    and my input is:abcdef1011addbbbd

    as soon as user write "1011" my flag variable should go from 0 to 1.
    note : user should not press enter and then check for the input string.


    Thanks in advance... any help is most welcome.
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    Originally Posted by luvmonti
    note : user should not press enter and then check for the input string.
    Ah well, this little trick requires you to tell us which OS and Compiler you're using.

    Standard C and C++ only deal with buffered standard input.
    So anything with a finer level of control (down to individual key presses) requires a more specific (that is, it won't work everywhere) answer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo