Main.m
1 #import<Foundation/Foundation.h>2 /**3 * Test the difference between the pointer type parameter and the common parameter4 *5 * @param A pointer-type parameter6 * @param b general Parameters7 *8 * @return (pointer type parameter +2) + (normal parameter +2)9 */Ten intPointertypeparametertest (int*a,intb) { One*a = *a +2;//the *a represents the value of a variable pointer (memory address) pointing to the memory storage space AB = B +2; - return*a+b; - } the intMainintargcConst Char*argv[]) { - @autoreleasepool { - intA =4; - intb =5; +NSLog (@"a=%d, b=%d &a=%p, &b=%p", A, B, &a, &b);//a=4, b=5 &a=0x7fff5fbff79c, &b=0x7fff5fbff798 -NSLog (@"Pointertypeparametertest (&a, b) =%d", Pointertypeparametertest (&a, b));//Pointertypeparametertest (&a, b) =13;&a to get the memory address of the A variable, b to get the value of the variable +NSLog (@"a=%d, b=%d; &a=%p, &b=%p, after the operation of Pointertypeparametertest (&a, b)", A, B, &a, &b);//a=6, b=5, &a=0x7fff5fbff79c, &b=0x7fff5fbff798, after the operation of Pointertypeparametertest (&a, B) /c8> A at - int*C; -c = &A; -NSLog (@"c=%d, a=%d &c=%p, c=%p, &a=%p", *c, A, &c, C, &a);//c=6, A=6 &c=0x7fff5fbff790, c=0x7fff5fbff79c, &a=0x7fff5fbff79c -*c =8; -NSLog (@"c=%d, a=%d &c=%p, c=%p, &a=%p", *c, A, &c, C, &a);//c=8, A=8 &c=0x7fff5fbff790, c=0x7fff5fbff79c, &a=0x7fff5fbff79c in } - return 0; to}
Results:
1 -- to- the -: the:11.593ocpointertypeparameter[562:21474] A=4, b=5; &a=0x7fff5fbff79c, &b=0x7fff5fbff7982 -- to- the -: the:11.594ocpointertypeparameter[562:21474] Pointertypeparametertest (&a, b) = -3 -- to- the -: the:11.594ocpointertypeparameter[562:21474] A=6, b=5; &a=0x7fff5fbff79c, &b=0x7fff5fbff798, after the operation of Pointertypeparametertest (&A, B)4 -- to- the -: the:11.594ocpointertypeparameter[562:21474] C=6, a=6; &c=0x7fff5fbff790, c=0x7fff5fbff79c, &a=0x7fff5fbff79c5 -- to- the -: the:11.595ocpointertypeparameter[562:21474] C=8, a=8; &c=0x7fff5fbff790, c=0x7fff5fbff79c, &a=0x7fff5fbff79c
Pointer-type parameters of objective-c syntax