Doubt!!!

This is a discussion on Doubt!!! within the C Programming forums, part of the General Programming Boards category; could somebody please explain how this works (Dos based): Code: int main( void) { int i ; char ch ; ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    14

    Doubt!!!

    could somebody please explain how this works (Dos based):

    Code:
       int main( void)
    
        {
    
           int i ;
    
          char ch ;  
    
          scanf("%d", &i);
          scanf("%c", &ch);
        
          if ( ch != 10)
             printf( "Error ");
          else
             printf (" %d ", i);
       }
    why is ch compared to 10 ?
    ....
    this gives "error" when i input a character instead of an integer.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    14
    does the value 10 have anything to do with the ascii codes ????

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    14
    thanks a lot.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doubt in pointer.
    By shwetha_siddu in forum C Programming
    Replies: 5
    Last Post: 03-21-2009, 01:28 AM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 12:49 PM
  3. Replies: 4
    Last Post: 12-10-2006, 06:08 PM
  4. Doubt abt Storage!
    By kalamram in forum C Programming
    Replies: 1
    Last Post: 04-21-2006, 05:30 AM
  5. Greatest C++ Doubt
    By vasanth in forum C++ Programming
    Replies: 15
    Last Post: 02-28-2002, 03:41 AM

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