質問するログイン新規登録

回答編集履歴

3

修正

2018/05/26 06:25

投稿

asm
asm

スコア15149

answer CHANGED
@@ -72,7 +72,7 @@
72
72
  {1,2},
73
73
  {2,3}
74
74
  };
75
- for(const person1 *cur = person, *end = cur + (sizeof(person) / sizeof(*person));
75
+ for(const person1 *cur = person, *const end = cur + (sizeof(person) / sizeof(*person));
76
76
  cur < end;
77
77
  cur++){
78
78
  printf("%d\n", cur->no1);

2

追記

2018/05/26 06:25

投稿

asm
asm

スコア15149

answer CHANGED
@@ -52,4 +52,30 @@
52
52
  引数は変数ではないという言葉遊びの域ですが[可能です。](https://wandbox.org/permlink/N91LJearMKW44pu8)
53
53
 
54
54
 
55
- あとは**繰り返し**の方法について指示がないのでCプリプロセッサを用いる事で可能なようにも思います。
55
+ あとは**繰り返し**の方法について指示がないのでCプリプロセッサを用いる事で可能なようにも思います。
56
+
57
+ ---
58
+
59
+ **追記**
60
+ あれ?`const`修飾したいだけなのかな?
61
+
62
+ ```c
63
+ #include <stdio.h>
64
+
65
+ typedef struct {
66
+ int no1;
67
+ int no2;
68
+ } person1;
69
+
70
+ int main(void){
71
+ person1 person[] = {
72
+ {1,2},
73
+ {2,3}
74
+ };
75
+ for(const person1 *cur = person, *end = cur + (sizeof(person) / sizeof(*person));
76
+ cur < end;
77
+ cur++){
78
+ printf("%d\n", cur->no1);
79
+ }
80
+ }
81
+ ```

1

修正

2018/05/26 04:21

投稿

asm
asm

スコア15149

answer CHANGED
@@ -25,7 +25,6 @@
25
25
 
26
26
  ```C
27
27
  #include <stdio.h>
28
- #include <stdbool.h>
29
28
 
30
29
  typedef struct {
31
30
  int no1;