C Language Fifth day note January 18, 2016 (Monday) a.m.

Source: Internet
Author: User

1. Functions (supplement, understanding)

function parameters have default values and must have default values from right to left

Example: int foo (int a,int b=1,int c=2) {

return a+b+c;} Legal

int foo (int a=1,int b,int c=2) {

return a+b+c;} Not legal

Inline functions: Use the inline keyword when declaring (and not necessarily all compilers support inline functions).

inline function: Before compiling, the compiler replaces the function call statement with the function body, eliminating the "Look for function implementation" time when executing. It's a space-time-changing operation.

Normal function: When the program runs, the compiler will find the function body according to the function name

Function overloading: (c + + features)

Function names are the same, parameter lists are different. The parameter list is divided into two cases, the number of parameters is different, the parameter type is different.

2. Pointers:

What is the 2.1 pointer? The pointer is the address.

Pointer variable: The address number is stored

Integer variables: integers are stored

2.2 Declaration Pointers

Declaring an integer variable: int A;

Declare pointer variable: base type * variable name;

Example: int* p; double** Q;

Base type: The variable type "point" of the pointer int* p;

P The base type of "point" is int type Q "point" double* type

"Point": Char achar= ' G ';

Char* p; The p=&achar;//pointer variable p Stores the address number of the Achar variable, which is called the pointer p to Achar.

3. Use of pointers

int A;

int* P=&a

int** qq=&p//Two-level pointer "point" level pointer

Print Address:%p

Print Length:%lu sizeof ()

Initialization

The variable p is an lvalue indicating that the space P is the value of the right value representing the space

Example: int A; int* Q; q=&a; Variable q initialization, so the left value is the variable name Q

int** QQ; qq=&q;

*:

int* (data type *): * indicates that P is a pointer variable.

*p: Address character

int a=10;

int* P =&a;

printf ("%d%d\n", a,*p);//10 10

*p=20; *p⇔* (&a) ⇔a

printf ("%d%d\n", a,*p);//20 20

int* *q=&p;

printf ("%d%d%d\n", a,*p,**q);//20 20 20

q=&p=& (&a); two-time value

return 0;

Null pointer: A null-valued pointer

C Language Fifth day note January 18, 2016 (Monday) a.m.

Related Article

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.