回答編集履歴
1
追記
answer
CHANGED
@@ -1,1 +1,47 @@
|
|
1
|
-
関数を作れば出来るかと思いましたが、関数の仮引数もだめだと言うことだと、無理でしょう。
|
1
|
+
関数を作れば出来るかと思いましたが、関数の仮引数もだめだと言うことだと、無理でしょう。
|
2
|
+
|
3
|
+
一応、関数版を書いておきます。
|
4
|
+
```C
|
5
|
+
#include <stdio.h>
|
6
|
+
|
7
|
+
typedef struct {
|
8
|
+
int no1;
|
9
|
+
int no2;
|
10
|
+
} person1;
|
11
|
+
|
12
|
+
void foo(person1 *p, person1 *q){
|
13
|
+
if(p<q){
|
14
|
+
printf("%d\n", p->no1);
|
15
|
+
foo(p+1, q);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
int main(void){
|
20
|
+
person1 person[] = {
|
21
|
+
{1,2},
|
22
|
+
{2,3},
|
23
|
+
};
|
24
|
+
foo(person, person+sizeof person/sizeof *person);
|
25
|
+
}
|
26
|
+
```
|
27
|
+
そもそも仮引数を使って良いなら、
|
28
|
+
```C
|
29
|
+
#include <stdio.h>
|
30
|
+
|
31
|
+
typedef struct {
|
32
|
+
int no1;
|
33
|
+
int no2;
|
34
|
+
} person1;
|
35
|
+
|
36
|
+
int main(int i){
|
37
|
+
person1 person[] = {
|
38
|
+
{1,2},
|
39
|
+
{2,3},
|
40
|
+
};
|
41
|
+
|
42
|
+
for(i=0; i<sizeof person/sizeof *person; i++){
|
43
|
+
printf("%d\n", person[i].no1);
|
44
|
+
}
|
45
|
+
|
46
|
+
}
|
47
|
+
```
|