Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Language Examples - Accessing Array Elements with Pointers

C Language Examples - Accessing Array Elements with Pointers

C Language Examples C Language Examples

Access array elements using pointers.

Example

#include

<
stdio.h
int
main
(
)
{
int
data
[
5
]
,
i

;

printf

(

"

Enter elements:

"

)

;

for

(

i

=

0

;

i

<

5

; ++

i

)

scanf

(

"

%d

"

,

data

i

)

;

printf

(

"

What you entered is:

\

n

"

)

;

for

(

i

=

0

;

i

<

5

; ++

i

)

printf

(

"

%d

\

n

"

, *

(

data

i

)

)

;

return

0

;

}

The output is:


输入元素: 1
2
3
5
4
What you entered is:
1
2
3
5
4

C Language Examples C Language Examples