Dark Horse Programmer--the function of "dark Horse video note" C Language Foundation

Source: Internet
Author: User

.

1. When to define a function: Add a common new feature

2. function definition Format return value type function name (formal argument list) {function Body}

3. Defining a function requires something clear 1> a meaningful function name 2> function parameter and return value selection

4. Note Points for parameters

   1:   1. Formal parameters: A parameter that is followed by a function name when defining a function, for short, a formal parameter
   2:   2. Actual parameters: Invoke the specific data passed in by the function, referred to as argument
   3:   3. The number of arguments must be equal to the number of parameters
   4:   4. A variable with the same parameters cannot be defined inside the function body
   5:   5. If the base data type is a function parameter, it is purely a value pass, modifying the value of a function's internal parameter without affecting the value of the outer argument
   6:   6. A function can have no formal parameter, or it can have an infinite number of parameters

The role of 5.return:
   1:   1> Exit function
   2:   2> Returns a specific value to the function caller
   3:   return value Note point
   4:   1> void represents no return value
   5:   2> If the return value type is not explicitly stated, the default is to return the int type
   6:   3> Even if the return value type is explicitly declared, no value can be returned
   7:   By default, the C language does not allow the same name as two functions

6. Steps to define a function
   1:  1> A meaningful name based on function
   2:  2> Determining the number of formal parameters of a function
   3:  3> Determining the return value of a function

7. Other precautions
   1:  1. By default, the name of a function is not allowed
   2:   2. Functions cannot be nested defined
   3:   3. Functions cannot be defined repeatedly, but can be declared repeatedly
   4:   4. If there is a function declaration, there is no definition of the function
   5:   1> compile can pass, because the compiler will only detect syntax is not reasonable, and does not detect the function has no definition
   6:   2> link error, because the link will detect whether the function is defined

Dark Horse Programmer--the function of "dark Horse video note" C Language Foundation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.