Advertisement
thenewboston

C Programming Tutorial - 32 - A Few Cool Character Functions

Aug 22nd, 2014
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. int main()
  6. {
  7.     // you can use ints and characters interchangeably in most cases
  8.     int tuna = 'b'; // b, 7, $
  9.  
  10.     if( isalpha(tuna) ){
  11.         printf("%c is a letter \n", tuna );
  12.     }else{
  13.         if( isdigit(tuna) ){
  14.             printf("%c is a number \n", tuna );
  15.         }else{
  16.             printf("%c is not a OMG IDK! \n", tuna );
  17.         }
  18.     }
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement