Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sept 22 2013
- //transform.xcodeproj
- //OS X 10.6.8
- //Xcode 4.2, Build 4C199
- //example of using a define and a define with MACRO argument
- #import <Foundation/Foundation.h>
- //this is a straigthforward text substitution:
- #define TRANSITION "Therefore"
- //this one takes an argument to test if one number is smaller than another
- //and to return the smallest - see how its employed in the first printf statement below
- #define MINY(a,b) ((a)<(b)) ? (a) : (b)
- int main (int argc, const char * argv[])
- {
- @autoreleasepool {
- int her = 31;
- int you = (3*1)+her;
- int me = 3*(1+her);
- //here's the macro employed to print the numbers
- printf("\n%i %s %i", MINY(me, you), ((!(me == you)) ? "is smaller than" : "equals"), (((MINY(me, you)) == me) ? you : me));
- //now we use another conditional to identify which value belonged to which variable
- if (me < you)
- //and here's the other #define statement:
- printf("\n%s, me is smaller than you.", TRANSITION);
- else if (me > you)
- printf("\n%s, you is smaller than me.", TRANSITION);
- else
- printf("\n%s, you and me are equal.", TRANSITION);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement