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
#include <stdio.h> void addtask(); void viewtask(); void edittask(); void deletetask(); char menu(); int main() { char selection ; do { selection = menu(); switch(selection) { case '1': addtask(); break; case '2': viewtask(); break; case '3': edittask(); break; case '4': deletetask(); break; case '5': break; default: printf("Invalid option"); } }while(selection != '1'); return 0; } char menu() { char option; printf("\n1) Add New Task"); printf("\n2) View Task"); printf("\n3) Edit Task"); printf("\n4) Delete Task"); printf("\n5) Exit"); printf("\nEnter option: "); scanf("%c[^\n]", &option); return option; } void addtask( ){ int utask, duedate, status, category, note; printf("\n\n\t\t---------------------------------\n"); printf("\t\t* Welcome to Add Task Menu! *"); printf("\n\t\t---------------------------------\n\n"); FILE * f = fopen("task.txt", "r+"); if(f == NULL) f = fopen("task.txt", "w"); else { fseek(f, 0, SEEK_END); printf("\nEnter your Task name:"); scanf("%s", &utask); printf("\nEnter your Task due date[yyyy-mm-dd]: "); scanf("%d", &duedate); printf("\nENTER progress percentage[0.00~100]:"); scanf("%f", &status); printf("\nEnter category: "); scanf("%s", &category); printf("\nEnter Note: "); scanf("%s", ¬e); fprintf(f,"%s %d %f %s %s\n", utask, duedate, status, category, note); } fclose(f); } void viewtask(){ int na, d, s, c, no; printf("\nThis is Your task details"); FILE * f = fopen("task.txt", "r"); while(fscanf(f,"%s",&na) != EOF){ fscanf(f,"%d",&d); fscanf(f,"%f",&s); fscanf(f,"%s",&c); fscanf(f,"%s",&no); 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); } fclose(f); } void update() { int utask, d, s, c, no, na; FILE * f = fopen("task.txt", "r"); FILE * ft = fopen("tmp.txt", "w"); printf("\nthis is edit task"); //変更 printf("\nEnter your task:"); scanf("%s", &utask); while(fscanf(f,"%s",&na) != EOF){ fscanf(f,"%d",&d); fscanf(f,"%f",&s); fscanf(f,"%s",&c); fscanf(f,"%s",&no); if(na == utask){ printf("\nUpdating >> your task: %s \t duedate: %d \t stasus: %f \t category: %s \t note: %s", na, d, s, c, no); printf("\nEnter new duedate:"); scanf("%d", &d); printf("\nEnter new progression:"); scanf("%f", &s); printf("\nEnter new category:"); scanf("%s", &c); printf("\nEnter new note:"); scanf("%s", &no); } fprintf(ft,"%s %d %f %s %s\n", na, d, s, c, no); } fclose(ft); fclose(f); remove("task.txt"); rename("tmp.txt", "task.txt"); } void delete() { int utask, d, s, c, no, na; FILE * f = fopen("data.txt", "r"); FILE * ft = fopen("tmp.txt", "w"); printf("\nthis is delete record"); printf("\nEnter utask:"); scanf("%d", &utask); while(fscanf(f,"%s",&na) != EOF){ fscanf(f,"%d",&d); fscanf(f,"%f",&s); fscanf(f,"%s",&c); fscanf(f,"%s",&no); if(na == utask){ printf("\nDelete -> your task: %s \t duedate: %d \t progression: %f \t category: %s \t note: %s", na, d, s, c, no); continue; } fprintf(ft,"%s %d %f %s %s\n", na, d, s, c, no); } fclose(ft); fclose(f); remove("task.txt"); rename("tmp.txt", "task.txt"); }
まだ回答がついていません
会員登録して回答してみよう