C言語で、タスク情報を記録できるシステムを作成しています。以下のソースコードから実行しようとすると
C:\Users\AppData\Local\Temp\ccQhtmBp.o:qq.c:(.text+0x3c): undefined reference to edittask' C:\Users\\AppData\Local\Temp\ccQhtmBp.o:qq.c:(.text+0x43): undefined reference to
deletetask'
のエラーが表示されプログラムがうまく実行できません。
エラーの原因及び修正箇所の提示をご教授していただけると幸いです。
c
1#include <stdio.h> 2 3void addtask(); 4void viewtask(); 5void edittask(); 6void deletetask(); 7char menu(); 8 9int main() { 10 char selection ; 11 do { 12 selection = menu(); 13 switch(selection) { 14 case '1': addtask(); break; 15 case '2': viewtask(); break; 16 case '3': edittask(); break; 17 case '4': deletetask(); break; 18 case '5': break; 19 default: printf("Invalid option"); 20 } 21 }while(selection != '1'); 22 return 0; 23} 24 25char menu() { 26 char option; 27 printf("\n1) Add New Task"); 28 printf("\n2) View Task"); 29 printf("\n3) Edit Task"); 30 printf("\n4) Delete Task"); 31 printf("\n5) Exit"); 32 printf("\nEnter option: "); 33 scanf("%c[^\n]", &option); 34 return option; 35} 36 37void addtask( ){ 38 int utask, duedate, status, category, note; 39 printf("\n\n\t\t---------------------------------\n"); 40 printf("\t\t* Welcome to Add Task Menu! *"); 41 printf("\n\t\t---------------------------------\n\n"); 42 43 FILE * f = fopen("task.txt", "r+"); 44 if(f == NULL) 45 f = fopen("task.txt", "w"); 46 else { 47 fseek(f, 0, SEEK_END); 48 printf("\nEnter your Task name:"); 49 scanf("%s", &utask); 50 printf("\nEnter your Task due date[yyyy-mm-dd]: "); 51 scanf("%d", &duedate); 52 printf("\nENTER progress percentage[0.00~100]:"); 53 scanf("%f", &status); 54 printf("\nEnter category: "); 55 scanf("%s", &category); 56 printf("\nEnter Note: "); 57 scanf("%s", ¬e); 58 fprintf(f,"%s %d %f %s %s\n", utask, duedate, status, category, note); 59 } 60 fclose(f); 61} 62 63void viewtask(){ 64 int na, d, s, c, no; 65 printf("\nThis is Your task details"); 66 FILE * f = fopen("task.txt", "r"); 67 while(fscanf(f,"%s",&na) != EOF){ 68 fscanf(f,"%d",&d); 69 fscanf(f,"%f",&s); 70 fscanf(f,"%s",&c); 71 fscanf(f,"%s",&no); 72 printf("\nYour Task: %s \t Task duedate: %d \t Task progression: %f \t Task category: %s \t Task note: %s",na, d, s, c, no); 73 } 74 fclose(f); 75} 76 77void update() { 78 int utask, d, s, c, no, na; 79 FILE * f = fopen("task.txt", "r"); 80 FILE * ft = fopen("tmp.txt", "w"); 81 printf("\nthis is edit task"); //変更 82 printf("\nEnter your task:"); 83 scanf("%s", &utask); 84 while(fscanf(f,"%s",&na) != EOF){ 85 fscanf(f,"%d",&d); 86 fscanf(f,"%f",&s); 87 fscanf(f,"%s",&c); 88 fscanf(f,"%s",&no); 89 if(na == utask){ 90 printf("\nUpdating >> your task: %s \t duedate: %d \t stasus: %f \t category: %s \t note: %s", na, d, s, c, no); 91 printf("\nEnter new duedate:"); 92 scanf("%d", &d); 93 printf("\nEnter new progression:"); 94 scanf("%f", &s); 95 printf("\nEnter new category:"); 96 scanf("%s", &c); 97 printf("\nEnter new note:"); 98 scanf("%s", &no); 99 } 100 fprintf(ft,"%s %d %f %s %s\n", na, d, s, c, no); 101 } 102 fclose(ft); 103 fclose(f); 104 remove("task.txt"); 105 rename("tmp.txt", "task.txt"); 106} 107 108void delete() { 109 int utask, d, s, c, no, na; 110 FILE * f = fopen("data.txt", "r"); 111 FILE * ft = fopen("tmp.txt", "w"); 112 printf("\nthis is delete record"); 113 printf("\nEnter utask:"); 114 scanf("%d", &utask); 115 while(fscanf(f,"%s",&na) != EOF){ 116 fscanf(f,"%d",&d); 117 fscanf(f,"%f",&s); 118 fscanf(f,"%s",&c); 119 fscanf(f,"%s",&no); 120 if(na == utask){ 121 printf("\nDelete -> your task: %s \t duedate: %d \t progression: %f \t category: %s \t note: %s", na, d, s, c, no); 122 continue; 123 } 124 fprintf(ft,"%s %d %f %s %s\n", na, d, s, c, no); 125 } 126 fclose(ft); 127 fclose(f); 128 remove("task.txt"); 129 rename("tmp.txt", "task.txt"); 130} 131
回答2件
あなたの回答
tips
プレビュー