Thread: key entered carry over next page

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    33

    key entered carry over next page

    Hmm seem like my password function is ok but I have one big problem.... After i enter the password, i have to press any key to continue to the menu page, they key i press will be carry over to the menu where menu is a selection page. I tried adding fflush(stdin) but can resolve.

    Anyone can help?

    PHP Code:
    if (strcmp(passpassword) == 0)
          {
        
    clrscr();
        
    mainpage();
        
    gotoxy(23,22);
        
    printf("Access granted! Press Any Key to Access Main Menu");
        
    getch();
        
    menu();
          }
        else
          {
        
    clrscr();
        
    mainpage();
        
    gotoxy(23,22);
        
    printf("Access denied! Press Any Key to Continue....");
        
    repeat++;
        
    getch();
        goto 
    Loop;


        }
        



  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Did you:
    Code:
    #include <conio.h>
    ? Just a try!

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    33
    yes the conio.h is included

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > goto Loop;
    Why don't you just use a real loop.
    The world is waiting. I must leave you now.

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    33
    real loop?

    hmmmmm, not sure how, sometime the more i change it, the more confusing the program it becomes and more unexpected errors appear

  6. #6
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

    Re: key entered carry over next page

    Originally posted by sturm100
    I tried adding fflush(stdin) but can resolve.
    fflush(stdin) is wrong.
    Search the borad on fflush stdin...

  7. #7
    Registered User
    Join Date
    May 2002
    Posts
    33
    Nevermind its ok

    I will rewrite the coding again

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It sounds to me like you just want to clear everything out of the input stream. In my experience the most effective way is:

    while ( getchar() != '\n' );

    -Prelude
    My best code is written with the delete key.

  9. #9
    Registered User
    Join Date
    May 2002
    Posts
    33
    Thanks for enlightening

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  2. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  3. Replies: 0
    Last Post: 02-21-2002, 06:05 PM
  4. heeeeeeellllllpppppppp!!!
    By DarkDays in forum C++ Programming
    Replies: 15
    Last Post: 12-09-2001, 09:43 PM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM