C Language Function Learning notes

Source: Internet
Author: User

What is a function

Any C language program is composed of one or more program segments (small programs). Each program segment has its own functionality, which we generally call "functions". So, you can say that the C language program is composed of functions.

Definition of two functions

1 Defining the purpose of a function

Save a common feature for later use.

2 steps to define a function

Function Name: What is the name of the functions?

Function Body: What does the function do and what code it contains.


3 format

Fixed format

Name of function

{

function contents

}


Return

1 Effects:

(1) Exit function

(2) returns a body value.

The function uses the note point:

(1) If the return value type is not explicitly declared, the default is the int type.

(2) Function name cannot be duplicated.

(3) Two functions call most of each other into the dead loop until the memory is fully occupied

Steps to define a function:

1 clear function, define a function name.

2 function body.

As follows:

void Huangcan ()
{
printf ("Huangcan");
}

If there is a declaration of a function, it cannot be called.
Error Example:
int main ()
{
Huangcan ();
}
void Huangcan ()
{
printf ("Huangcan");
}

Because the compiler defaults to compiling from the top down
No correlation function declaration was obtained before calling function

C Language Function Learning notes

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.