c函数、数组、指针和调试器gdb--函数(C functions, arrays, pointers, and debugger gdb-- functions).docVIP

  • 4
  • 0
  • 约1.41万字
  • 约 15页
  • 2018-06-10 发布于江西
  • 举报

c函数、数组、指针和调试器gdb--函数(C functions, arrays, pointers, and debugger gdb-- functions).doc

c函数、数组、指针和调试器gdb--函数(C functions, arrays, pointers, and debugger gdb-- functions).doc

c函数、数组、指针和调试器gdb--函数(C functions, arrays, pointers, and debugger gdb-- functions) Definition of function 1, the general form of function (function) is defined as: Returns the type function name (list of formal arguments) { Function body } In the C language, functions are uniquely identified by function names. A function name is an identifier that does not have the same name as other functions. Otherwise, when the function calls, the system does not know which one to call. But as in the extension of the C + + language for the C language, function allows the same. The return type of a function is the type that returns the value when calling the function, and can be any basic data type or pointer. When the function does not return any value, it should be defined that the return type of the function is void. If you do not specify a return type when defining a function, the most commonly used compiler Linux on GCC is the default return type of int. A formal parameter is the operand of a function, separated by commas. The part of a function that performs an operation is called a function body. You can define variables in the body of the function, manipulate the formal parameters, and return the data. The following definition of a function, used to find the larger of the two numbers, the code is as follows: Int max (int, a, int, b) { Int c; C = ab? A:b; Return c; } In the first line, the first keyword, int, indicates the return type of this function is integer. Max is the function name, and there are two formal arguments in parentheses. They are all integer, and the parameters are separated by commas. The first line in the function body defines an integer variable C, and the second line will assign the larger value in a and B to C. The last line of the function body returns the value of the variable C to the caller by using the return statement. Here we notice that the type of the variable C is consistent with the return type of the function, both of which are of type int.

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档