fgetc problem

This is a discussion on fgetc problem within the C Programming forums, part of the General Programming Boards category; hey guys im trying to check whether a user has keyed in a certain character whether that be 's' 'u' ...

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    fgetc problem

    hey guys im trying to check whether a user has keyed in
    a certain character whether that be 's' 'u' or 'f' and if they have not keyed in those characters i want it to loop back and ask for input again.


    i need to use something like fgetc or something like that which is able to input just a simple char.
    If its bad input how do i get it to ask for input again

    Code:
    do
    {
    
       if(type != 's' || type != 'u' || type != 'f')
       {
    
             printf("wrong input only s, uor f is accepted");
          
    
       }
    
    
    }
    while(type = fgetc(stdin)) != '\n' && type != EOF));

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    break;
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. possible problem with fgetc?????
    By iamvarg in forum C Programming
    Replies: 4
    Last Post: 11-15-2006, 11:51 AM

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