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

質問編集履歴

7

エラーが減りました。

2016/08/05 10:22

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -14,8 +14,16 @@
14
14
 
15
15
  int main(void)
16
16
  {
17
+ student data[] = {
17
- student data[] = { 1,2,3,"A",12.3,45.6};
18
+ { 1,2,3,"A",12.3,45.6}
19
+ , { 1,2,4,"B",12.3,45.6}
20
+ , { 1,2,5,"C",12.3,45.6}
21
+ , { 1,2,6,"D",12.3,45.6}
22
+ , { 1,2,7,"E",12.3,45.6}
23
+ , { 1,2,8,"F",12.3,45.6}
24
+ , { 1,2,9,"G",12.3,45.6}
25
+ };
18
- student_print(student data[],int 7);
26
+ student_print(data, 7);
19
27
  return;
20
28
  }
21
29
 
@@ -35,12 +43,9 @@
35
43
  ```
36
44
  エラーメッセジが次のようにでます。
37
45
  prog.cc: In function 'int main()':
38
- prog.cc:18:27: error: expected primary-expression before 'data'
46
+ prog.cc:27:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
39
- student_print(student data[],int 7);
47
+ return;
40
- ^~~~
48
+ ^~~~~~
41
- prog.cc:18:34: error: expected primary-expression before 'int'
42
- student_print(student data[],int 7);
43
- ^~~
44
49
 
45
50
  環境はwiondows7 です。
46
51
  今、苦しんで学ぶc言語というサイトで勉強中なのですが、上のプログラミングが上手くいきません。よろしくお願いします。

6

全角をすべて半角にしました。

2016/08/05 10:22

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -2,12 +2,12 @@
2
2
  #include <string.h>
3
3
 
4
4
  struct student {
5
- int year; /* 学年 */
5
+ int year; /* 学年 */
6
- int clas; /* クラス */
6
+ int clas; /* クラス */
7
- int number; /* 出席番号 */
7
+ int number; /* 出席番号 */
8
- char name[64]; /* 名前 */
8
+ char name[64]; /* 名前 */
9
- double stature; /* 身長 */
9
+ double stature;/* 身長 */
10
- double weight; /* 体重 */
10
+ double weight; /* 体重 */
11
11
  };
12
12
 
13
13
  void student_print(student data[],int count);
@@ -34,9 +34,13 @@
34
34
  }
35
35
  ```
36
36
  エラーメッセジが次のようにでます。
37
+ prog.cc: In function 'int main()':
38
+ prog.cc:18:27: error: expected primary-expression before 'data'
39
+ student_print(student data[],int 7);
40
+ ^~~~
37
- prog.cc:27:46: error: stray '\343' in program
41
+ prog.cc:18:34: error: expected primary-expression before 'int'
38
- printf("[クラス]:%d\n",data[i].clas);
42
+ student_print(student data[],int 7);
39
- ^
43
+ ^~~
40
44
 
41
45
  環境はwiondows7 です。
42
46
  今、苦しんで学ぶc言語というサイトで勉強中なのですが、上のプログラミングが上手くいきません。よろしくお願いします。

5

コードブロックで囲んでみました。

2016/08/05 10:16

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- #include <stdio.h>
1
+ ```#include <stdio.h>
2
2
  #include <string.h>
3
3
 
4
4
  struct student {
@@ -32,7 +32,7 @@
32
32
  }
33
33
  return;
34
34
  }
35
-
35
+ ```
36
36
  エラーメッセジが次のようにでます。
37
37
  prog.cc:27:46: error: stray '\343' in program
38
38
  printf("[クラス]:%d\n",data[i].clas);

4

printfの末尾にある全角を取り除きました。

2016/08/05 10:08

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -21,19 +21,18 @@
21
21
 
22
22
  void student_print(student data[],int count)
23
23
  {
24
- int i;
24
+ int i;
25
- for (i = 0;i < count;i++) {
25
+ for (i = 0;i < count;i++) {
26
26
  printf("[学年]:%d\n",data[i].year);
27
- printf("[クラス]:%d\n",data[i].clas);
27
+ printf("[クラス]:%d\n",data[i].clas);
28
28
  printf("[出席番号]:%d\n",data[i].number);
29
29
  printf("[名前]:%s\n",data[i].name);
30
30
  printf("[身長]:%f\n",data[i].stature);
31
31
  printf("[体重]:%f\n",data[i].weight);
32
- }
32
+ }
33
- return;
33
+ return;
34
34
  }
35
35
 
36
-
37
36
  エラーメッセジが次のようにでます。
38
37
  prog.cc:27:46: error: stray '\343' in program
39
38
  printf("[クラス]:%d\n",data[i].clas);

3

エラーメッセージが減りました。

2016/08/05 09:59

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -15,7 +15,8 @@
15
15
  int main(void)
16
16
  {
17
17
  student data[] = { 1,2,3,"A",12.3,45.6};
18
- student_print(student data[],int 6);
18
+ student_print(student data[],int 7);
19
+ return;
19
20
  }
20
21
 
21
22
  void student_print(student data[],int count)
@@ -34,23 +35,9 @@
34
35
 
35
36
 
36
37
  エラーメッセジが次のようにでます。
37
- prog.cc:26:46: error: stray '\343' in program
38
+ prog.cc:27:46: error: stray '\343' in program
38
39
  printf("[クラス]:%d\n",data[i].clas);
39
40
  ^
40
- prog.cc:26:47: error: stray '\200' in program
41
- printf("[クラス]:%d\n",data[i].clas);
42
- ^
43
- prog.cc:26:48: error: stray '\200' in program
44
- printf("[クラス]:%d\n",data[i].clas);
45
- ^
46
- prog.cc:26:49: error: stray '\343' in program
47
- printf("[クラス]:%d\n",data[i].clas);
48
- ^
49
- prog.cc:26:50: error: stray '\200' in program
50
- printf("[クラス]:%d\n",data[i].clas);
51
- ^
52
- prog.cc:26:51: error: stray '\200' in program
53
- printf("[クラス]:%d\n",data[i].clas);
54
41
 
55
42
  環境はwiondows7 です。
56
43
  今、苦しんで学ぶc言語というサイトで勉強中なのですが、上のプログラミングが上手くいきません。よろしくお願いします。

2

エラーメッセージを更新しました。

2016/08/05 09:48

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -15,7 +15,7 @@
15
15
  int main(void)
16
16
  {
17
17
  student data[] = { 1,2,3,"A",12.3,45.6};
18
- student_print(student data[],int 7);
18
+ student_print(student data[],int 6);
19
19
  }
20
20
 
21
21
  void student_print(student data[],int count)
@@ -34,24 +34,23 @@
34
34
 
35
35
 
36
36
  エラーメッセジが次のようにでます。
37
- prog.cc:26:43: error: stray '\343' in program
38
- printf("[クラス]:%d\n",data[i].clas);
39
- ^
40
- prog.cc:26:44: error: stray '\200' in program
41
- printf("[クラス]:%d\n",data[i].clas);
42
- ^
43
- prog.cc:26:45: error: stray '\200' in program
44
- printf("[クラス]:%d\n",data[i].clas);
45
- ^
46
37
  prog.cc:26:46: error: stray '\343' in program
47
- printf("[クラス]:%d\n",data[i].clas);
38
+ printf("[クラス]:%d\n",data[i].clas);
48
39
  ^
49
40
  prog.cc:26:47: error: stray '\200' in program
50
- printf("[クラス]:%d\n",data[i].clas);
41
+ printf("[クラス]:%d\n",data[i].clas);
51
42
  ^
52
43
  prog.cc:26:48: error: stray '\200' in program
53
- printf("[クラス]:%d\n",data[i].clas);
44
+ printf("[クラス]:%d\n",data[i].clas);
54
45
  ^
46
+ prog.cc:26:49: error: stray '\343' in program
47
+ printf("[クラス]:%d\n",data[i].clas);
48
+ ^
49
+ prog.cc:26:50: error: stray '\200' in program
50
+ printf("[クラス]:%d\n",data[i].clas);
51
+ ^
52
+ prog.cc:26:51: error: stray '\200' in program
53
+ printf("[クラス]:%d\n",data[i].clas);
55
54
 
56
55
  環境はwiondows7 です。
57
56
  今、苦しんで学ぶc言語というサイトで勉強中なのですが、上のプログラミングが上手くいきません。よろしくお願いします。

1

Printfの前の全角を半角へ変更しました。

2016/08/05 09:41

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -14,20 +14,20 @@
14
14
 
15
15
  int main(void)
16
16
  {
17
- student data[] = { 1,2,,3,"",12.3,45.6};
17
+ student data[] = { 1,2,3,"A",12.3,45.6};
18
- student_print(student data[],int 6);
18
+ student_print(student data[],int 7);
19
19
  }
20
20
 
21
21
  void student_print(student data[],int count)
22
22
  {
23
23
  int i;
24
24
  for (i = 0;i < count;i++) {
25
- printf("[学年]:%d\n",data[i].year);
25
+ printf("[学年]:%d\n",data[i].year);
26
- printf("[クラス]:%d\n",data[i].clas);
26
+ printf("[クラス]:%d\n",data[i].clas);
27
- printf("[出席番号]:%d\n",data[i].number);
27
+ printf("[出席番号]:%d\n",data[i].number);
28
- printf("[名前]:%s\n",data[i].name);
28
+ printf("[名前]:%s\n",data[i].name);
29
- printf("[身長]:%f\n",data[i].stature);
29
+ printf("[身長]:%f\n",data[i].stature);
30
- printf("[体重]:%f\n",data[i].weight);
30
+ printf("[体重]:%f\n",data[i].weight);
31
31
  }
32
32
  return;
33
33
  }