質問編集履歴

2

先ほどのコードではコンパイル失敗してしまうため、コードの追記を行いました。大変申し訳ございません。

2022/06/06 06:36

投稿

yuto_jake
yuto_jake

スコア42

test CHANGED
File without changes
test CHANGED
@@ -23,7 +23,74 @@
23
23
  #include <string.h>
24
24
  #include <stdlib.h>
25
25
 
26
+ void addtask();
27
+ void edittask();
28
+ char menu();
29
+
26
- int main(){
30
+ int main()
31
+ {
32
+ char selection;
33
+ do
34
+ {
35
+ selection = menu();
36
+ switch(selection)
37
+ {
38
+ case '0': addtask();
39
+ break;
40
+ case '1': edittask();
41
+ break;
42
+ case '9': printf("\nThank you for using Task manager!!^^");
43
+ exit(0);
44
+ default:
45
+ printf("\nYou entered wrong choice...");
46
+ printf("\nPress any key to try again");
47
+ break;
48
+ }
49
+ }
50
+ while(selection != '10');
51
+ return 0;
52
+ }
53
+
54
+ char menu()
55
+ {
56
+ printf("\n\n\nWelcome to Task Management System!");
57
+ printf("\nThis is Main Menu");
58
+ char option;
59
+ printf("\n0) Add New Task");
60
+ printf("\n1) Edit your Task");
61
+ printf("\n9) Exit");
62
+ printf("\nEnter your choice:");
63
+ scanf("%c[^\n]", &option);
64
+ return option;
65
+ }
66
+
67
+ void addtask()
68
+ {
69
+ char tsn[10];
70
+ int duedate, p, cate;
71
+
72
+ printf("\n***** This is add new Task *****");
73
+ FILE * f = fopen("taskdata.txt", "r+");
74
+ if(f == NULL)
75
+ f = fopen("taskdata.txt", "w");
76
+ else
77
+ {
78
+ fseek(f, 0, SEEK_END);
79
+ printf("\nEnter your Task name:");
80
+ scanf("%s", tsn);
81
+ printf("\nEnter your Task due date[ex:20220518]:");
82
+ scanf("%d", &duedate);
83
+ printf("\nEnter your Task progression[0~100]:");
84
+ scanf("%d", &p);
85
+ printf("\nEnter Task category 1;study 2;work 3;other:");
86
+ scanf("%d", &cate);
87
+ fprintf(f,"%s %d %d %d\n", tsn, duedate, p, cate);
88
+ printf("\nYour task is just added successfully!");
89
+ }
90
+ fclose(f);
91
+ }
92
+
93
+ void edittask(){
27
94
  char tsn[10];
28
95
  char ntsn[10];
29
96
  int duedate, p, cate;

1

defineを追記しました

2022/06/06 06:13

投稿

yuto_jake
yuto_jake

スコア42

test CHANGED
File without changes
test CHANGED
@@ -18,6 +18,11 @@
18
18
  以下にソースコードをupしますので、原因と解決方法をご教授いただけますと幸いです。
19
19
 
20
20
  ```c
21
+ #include <stdio.h>
22
+ #include <stdlib.h>
23
+ #include <string.h>
24
+ #include <stdlib.h>
25
+
21
26
  int main(){
22
27
  char tsn[10];
23
28
  char ntsn[10];