回答編集履歴

2

変更

2017/01/29 06:12

投稿

A.Ichi
A.Ichi

スコア4070

test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- score = (double *)malloc(sizeof(double) * (ct + 10));
19
+ score = (double *)malloc(sizeof(double) * 10);
20
20
 
21
21
  printf("input numeric data & quit first charactor is not numeric\n");
22
22
 

1

変更

2017/01/29 06:12

投稿

A.Ichi
A.Ichi

スコア4070

test CHANGED
@@ -26,7 +26,13 @@
26
26
 
27
27
  if ( ct != 0 && ( ct % 10 ) == 0 ){
28
28
 
29
- score = (double *)realloc(score,sizeof(double) * (ct + 10));
29
+ if ((score = (double *)realloc(score,sizeof(double) * (ct + 10))) == NULL) {
30
+
31
+ printf("realloc時にメモリが確保できません\n");
32
+
33
+ exit(3);
34
+
35
+ }
30
36
 
31
37
  }
32
38