0

I am a beginner in C and I'm facing this error in Xcode when I'm writing my C code. I've seen the other questions here on StackOverflow but it doesn't seem to solve my problem. I think it has something to do with linking libraries but I'm not sure how to do that.

This is my code below:

#include<stdio.h>
#include<stdlib.h>

void add_task(void);
void view_task(void);
void manage_task(void);

int main()
{
    char main_choice;
    system("cls");
    printf("Welcome to your Task Management Sytem\n");
    printf("What would you like to do today?\n A: Add New Task\n B: View Task \n C: Manage Tasks\n");
    printf("\nEnter your choice:");
    scanf("%c", &main_choice);
    
    add_task();
    view_task();
    manage_task();
    
    switch(main_choice)
    {
        case 'A':
        {
            printf("\n--------------ADD A NEW TASK-------------");
            add_task();
            break;
        }
        case 'B':
        {
            printf("\n--------------VIEW A TASK-------------");
            view_task();
            break;
        }
        case 'C':
        {
            printf("\n--------------MANAGE TASKS-------------");
            manage_task();
            break;
        }
        default:
            printf("INVALID INPUT");
            break;
    }
}
void add_task()
{
    char name[20];
    char category[20];
    char info[20];
    char date[20];
    char status[20];

    printf("\nTo Add a new task enter the details below\n");
    printf("Name of Task:");
    scanf(" %s", name);
    printf("Category of Task:");
    scanf(" %s", category);
    printf("Information about task:");
    scanf(" %s", info);
    printf("Due Date of Task(dd/mm/yyyy):");
    scanf(" %s", date);
    printf("Status of Task\n TD = To-Do\n IP = In Progress\n CT = Completed Task\nEnter Status:");
    scanf(" %s", status);
}
void view_task()
{
    char task_choice;
    printf("View Tasks by:\nA:Due Date\nB:Category\nC:Status\nD:View All Tasks");
    scanf(" %c", &task_choice);
    if (task_choice == 'A')
    {
        char date_choice;
        printf("A:View Tasks in ascending order\nB: View Tasks in descending order\nEnter your choice:");
        scanf(" %c", &date_choice);
    }
}

void manage_task()
{
    printf("What do you want to change");
}

.........................................................................................

HannahJ
  • 39
  • 7
  • Why are you calling add_task(), view_task(), manage_task() before switch control itself? Remove those 3 calls. – Bharat S May 06 '22 at 04:58
  • Alright but it still doesnt work – HannahJ May 06 '22 at 04:59
  • This answer should help you: https://stackoverflow.com/a/63584328/2232149 You need to use flag `-lcurses` in your compilation and linking process – Bharat S May 06 '22 at 05:04
  • 1
    @BharatS *why* ? there are no curses APis used in this code, nor included for decl via header pulls. – WhozCraig May 06 '22 at 05:09
  • Alright well I looked into but I'm new to Xcode and I'm not sure on how to do that – HannahJ May 06 '22 at 05:11
  • *I think it has something to do with linking libraries* Showing how you link or what libraries you added in your IDE would be a good idea, then. – Gerhardh May 06 '22 at 06:52
  • Do you have some code that actually calls these functions? I can't find them in the snippet you show. – Gerhardh May 06 '22 at 06:53
  • When you compile, some text should be displayed somewhere in a dedicated window, it's the compilation command. **Could you show us the compilation command**? (starting with `cc`, `gcc`, or `clang`) – Mathieu May 06 '22 at 06:58
  • How can I show these commands – HannahJ May 06 '22 at 07:00

0 Answers0