質問編集履歴
1
質問内容とタグ
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,24 +1,2 @@
|
|
1
1
|
値渡しとポインタ渡しの説明を詳しく、わかりやすく知りたいです。
|
2
|
-
下のプログラムで、教えてください。
|
3
|
-
---
|
4
|
-
#include <stdio.h>
|
5
|
-
void test(int a, int *b, int c[], int *d, int *e){
|
6
2
|
|
7
|
-
int tmp;
|
8
|
-
tmp = a; a = *b; *b = tmp;
|
9
|
-
tmp = c[0]; c[0] = c[1]; c[1] = tmp;
|
10
|
-
tmp = *d; *d = *e; *e = tmp;
|
11
|
-
|
12
|
-
}
|
13
|
-
int main(void){
|
14
|
-
|
15
|
-
int x = 1, y = 2, z[3] = {3, 4, 5}, *p, *q;
|
16
|
-
p = &z[1]; q = &z[2];
|
17
|
-
test(x, &y, z, p, q);
|
18
|
-
printf("x = %d, y = %d, z[0] = %d, z[1] = %d, z[2] = %d¥n",
|
19
|
-
|
20
|
-
x, y, z[0], z[1], z[2]);
|
21
|
-
|
22
|
-
return 0;
|
23
|
-
|
24
|
-
}
|