1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Kochan 2.0 Exercise 12-6

Discussion in 'Mac Programming' started by mdeh, Jan 26, 2009.

  1. macrumors 6502

    #1
    Any feedback is welcome.

    Code:
    #import <Foundation/Foundation.h>
    
    #define IS_UPPER_CASE(c)  (((c) >= 'A') && ((c) <= 'Z'))
    #define IS_LOWER_CASE(c)  (((c) >= 'a' ) && (( c) <= 'z'))
    #define IS_ALPHABETIC(c)  (IS_UPPER_CASE(c) || IS_LOWER_CASE(c))
    #define IS_DIGIT(c) ((c) >= '0') && ((c) <= '9')
    #define IS_SPECIAL(c) (!IS_ALPHABETIC(c) ) && ( !IS_DIGIT(c) )
    
    int main (int argc, const char * argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    	
    	char c = 'w', d = '0', e = '\t';
    	
        if (IS_SPECIAL(c))
    		NSLog(@"%c is a special char eg tab, whitespace", c);
    	else
    		NSLog(@"%c  is not a special char eg tab, whitespace", c);
    	
    	if (IS_SPECIAL(d))
    		NSLog(@"%c is a special char eg tab, whitespace", d);
    	else
    		NSLog(@"%c  is not a special char eg tab, whitespace", d);
    	
    	if (IS_SPECIAL(e))
    		NSLog(@"%c is a special char eg tab, whitespace", e);
    	else
    		NSLog(@"%c  is not a special char eg tab, whitespace", e);
    	
    	[pool drain];
        return 0;
    }
     

Share This Page