Four pointers and array five functions

Source: Internet
Author: User

Four pointers and arrays

< a > pointer is the address

1 define int *p;

2 Initializing int a,*p=&a;

Give the address of a to *p.

The pointer variable has whose address is pointing to WHO. The *p represents this variable. *P represents a

3 operation

int a,*p=&a;

*p=5; <-----assigned a 5 to a

int *p,a;

*p=[*&]a;

| Offset the

*p <=>a Equivalence

NOTE: * Three uses 1 multiplication operation 2 operator 3 specifier

Define time to use such as int a,*p=&a;

A two-array character array also requires

1 Defining one-dimensional two-dimensional both will be

2 Initialize one-dimensional two-dimensional to be back

3 element Reference

Citation----> Subscript method A[i]

-----> Pointer method: Precondition: Pointer pointing first to re-reference (int a[10],*p=a;)

P+i or a+i represents the address of the element I

* (P+i) or * (a+i) First element

4 element Assignment

Initialization

Input from keyboard

enter int a[10],*p=a; Output int ....

for (i=0;i<=j;i++) for ...

                                                scanf ("%d", &a[i]);                               printf ("%d", * (P+i));

                                                                 P+i                                                     or * (a+i)

C++

5 String function Copy connection you're going to make it.

The key points and difficulties in five-function test centers

1 functions first type function name parameter

{

function body

}

2 Return of function and type of function

Encounters | return expression; Expression type is the function type <---has a return value

return |  Return void type

| }

For example

Main () {

int s;

Xxxx

s = Fun (s); <----has a return value

Xxxx

}

int fun (int x) {

Xxxx

return expression;

}

Main () {void fun (int x) {...}

int s;

Fun (s); <-----no return value

}

Main () {void fun (int x) {...}

int s;

printf ("%f", Fun (s));

return value and the function value is float

}

Main () {float fun (int x) {return;}

int s;

printf ("%f", Fun (s));

}----> has a return value and the function value is float

3 function calls

1> principle:1> first defined and then called 2> if it violates the 1 principle, it needs the first part of function description;

4 parameter pass key is tuned

Call-time argument-----value 1-----> Parameter

<-----2--------

return expression

Call End

Four pointers and array five functions

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.