3.C language Features//3.1 function definition//function return type function name (parameter) {//dosomthing//} General function definitions are like this,//There is an ancient function definition, and another line to explain the parameters of void Printmesg (ms g,loopnum) int loopnum; int msg; {int i; for (i = 0;i<loopnum;i++) {printf ("%d cycles%d \ n", i+1,msg); }}//3.2 function declaration//function declaration is used for the use of functions before the definition of int add (int a,int b); int main () {//int maxInt = Add (3,8); } int Add (int a,int b) {return a+b; } The//3.3 parameter is passed, OBJECT-C uses the value to pass void swap (int a,int b) {int temp = A; A = b; b = temp; printf ("A is the value of%d,b is%d", A, b); }//For pointer-type variables, the same is used for value passing/* Draw is a class with two attributes int a,int b; void swap (Draw * DW) {int temp = DW.A; DW.A = dw.b; dw.b = temp; } int main () {Draw DW = [Draw alloc] init]; DW.A = 6; dw.b = 9; return 0; } *///DW is a pointer variable that is passed when the value is passed, and the pointer itself is copied,//But it is strange that the pointer is manipulating a draw object, regardless of which pointer, the//is the draw object. So the attribute change is taken for granted.//3.4 recursive function//3.5 intrinsic function and external function/* Intrinsic function: The definition uses a static modifier, which can only be called by a function in the current source file, so it is called an inner function external function: the definition uses an extern decoration, or does not use any modifiers, he can Called by any source file, this function is called an external function, and the general function is an external function. *///define extern function, omit exTern is also allowed extern printrect (int height,int width) {for (int. i=0;i
iOS Getting Started Tutorial (iii)-C language Features