質問編集履歴

4

プログラムの書き直し

2021/07/19 15:42

投稿

SUNMOON_14
SUNMOON_14

スコア20

test CHANGED
File without changes
test CHANGED
@@ -28,19 +28,11 @@
28
28
 
29
29
  if(fgets(buf, 1024, stdin) == NULL){
30
30
 
31
- if(scanf("%1023s", buf) == EOF){
32
-
33
- return 0;
31
+ exit(0);
34
-
35
- }
36
-
37
- printf("\n");
38
-
39
- continue;
40
-
41
-   (略)
42
32
 
43
33
  }
34
+
35
+ (以下、入力がきちんと与えられたときの処理)
44
36
 
45
37
  }
46
38
 

3

補足

2021/07/19 15:42

投稿

SUNMOON_14
SUNMOON_14

スコア20

test CHANGED
File without changes
test CHANGED
@@ -37,6 +37,8 @@
37
37
  printf("\n");
38
38
 
39
39
  continue;
40
+
41
+   (略)
40
42
 
41
43
  }
42
44
 

2

誤字

2021/07/19 15:31

投稿

SUNMOON_14
SUNMOON_14

スコア20

test CHANGED
File without changes
test CHANGED
@@ -20,11 +20,11 @@
20
20
 
21
21
  char buf[1024];
22
22
 
23
- char prompt_str[NAMESIZE] = "Command: ";
23
+ char prompt[NAMESIZE] = "Command: ";
24
24
 
25
25
  for(;;){
26
26
 
27
- printf("%s", prompt_str);
27
+ printf("%s", prompt);
28
28
 
29
29
  if(fgets(buf, 1024, stdin) == NULL){
30
30
 

1

追記

2021/07/19 15:30

投稿

SUNMOON_14
SUNMOON_14

スコア20

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,11 @@
20
20
 
21
21
  char buf[1024];
22
22
 
23
+ char prompt_str[NAMESIZE] = "Command: ";
24
+
23
25
  for(;;){
26
+
27
+ printf("%s", prompt_str);
24
28
 
25
29
  if(fgets(buf, 1024, stdin) == NULL){
26
30