05-Function, String

Source: Internet
Author: User

First, what is a function

* any C language Program is composed of one or more program segments (small programs), each of which has its own function, which we generally call " functions ".

* For example , in C language to write a MP3 player program, then its program structure as shown:

Second, the definition of function

1. steps to define a function

* function Name: What is the function name

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

2. format

* Fixed format

return value type  function name (formal argument list) {    function Body}

* Example

SUM (intint  b) {    int c = a + b;}

Iii. parameters of the function

* The pass of a parameter is a value pass

* Parameter name cannot be the same as local variable within function

Four, function notice

* cannot nest defined functions

* dead Loop call, call yourself

* cannot be defined repeatedly and can be declared repeatedly

Five, function supplement

1. main function

* return value:0, normal exit,1, abnormal exit

2. printf functions

* #include

* return Value: Length of String

Vi.#include

1. The role of #include

It's purely a file copy.

Seven, array

1. features of the array

* only one type of data can be stored, such as an array of type int , an array of type float

* data stored inside is called " element "

2. Array Definitions

* declaring the type of an array

* Declare the number of elements in an array (how much storage space is required)

3. format

Element type array name [ number of elements ];

Like what:

int ages[3];

4. Initialize

int ages[5] = {35}; int ages[3] = {2}; int a[] = {n};

Eight, string

1. What is a string

* Simple string "ASI"

* one ' i ' is a character

2. Initialization of strings

3. commonly used string processing functions

* strlen(note Chinese)  

05-Function, String

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.