Thread: character comparision

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    6

    character comparision

    how to compare an input character
    for example: input is 'c'
    if the input is 'c'
    print "123"
    else
    print "456"

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Code:
    ch = getchar();
    if ( ch == 'c' ) {
       printf( "123\n" );
    } else {
       // ...
    }
    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.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    6
    Originally posted by Salem
    Code:
    ch = getchar();
    if ( ch == 'c' ) {
       printf( "123\n" );
    } else {
       // ...
    }



    thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. syntax error when defining vectors
    By starkhorn in forum C++ Programming
    Replies: 5
    Last Post: 09-22-2004, 12:46 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM