链接器错误未定义参考,需要帮助,结构数组

时间:2015-08-14 18:24:13

标签: c++ arrays structure dev-c++

你好我们正在做我的C ++项目作业,我在这里遇到问题,因为

而无法编译
"[Linker error] undefined reference to " Thingy 

所以基本上我的程序更像是企业。

#include<stdio.h>
#include<conio.h>
#define FLUSH while(getchar()!='\n')
#include<stdlib.h>


typedef struct
{
    int ItemNumber;
    char ItemName[30];
    short ItemQuantity;
    float ItemPrice;
} ITEM;

int AddNewItem(ITEM[], int);
void EditItemInfo(ITEM[], int);
void Sales(ITEM[], int);
void GoodReceipts(ITEM[], int);
void DisplayAllItems(ITEM[], int);


int main(void)
{
    int int_choice;
    int int_counter = 0;
    ITEM num1[30];
    int ans;

    do
    {
        printf("Welcome to Tayona's Enterprise\n");
        printf("\n1] Add New Item");
        printf("\n2] Edit Item Information");
        printf("\n3] Sales");
        printf("\n4] Goods Receipt");
        printf("\n5] Display All Items");
        printf("\n6] Exit\n");
        printf("\n\nChoice:");
        scanf("%d", &int_choice);

        switch (int_choice)
        {
        case 1:int_counter = AddNewItem(num1, int_counter);
            break;
        case 2:EditItemInfo(num1, int_counter);
            break;
        case 3:Sales(num1, int_counter);
            break;
        case 4:GoodReceipts(num1, int_counter);
            break;
        case 5:DisplayAllItems(num1, int_counter);
            getch();
        case 6:break;
        default: printf("\nPlease Try Agian...");
        }

        if ((int_choice <= 0) || (int_choice >= 7))
        {
            printf("\nNot Found in the Selection, Please Try Agian...");
            getch();
        }

        system("cls");
    } while (int_choice != 6);
    return 0;
}
int AddNewItem(ITEM num1[], int int_counter)
{
    system("cls");
    char DetailsItem[30];
    int i = 0;
    int n;
    printf("Input item number:");
    scanf("%d", &num1[i].ItemNumber);
    fflush(stdin);

    int_counter++;
    {
        fflush(stdin);
        printf("Input item name:");
        scanf("%s", num1[i].ItemNumber);
        fflush(stdin);
        printf("Input quantity:");
        scanf("%hd", &(num1[i]).ItemQuantity);
        fflush(stdin);
        printf("Input item price:");
        scanf("%f", &(num1[i]).ItemPrice);
    }
    return int_counter;
}
void editItemInfo(ITEM num1[], int int_counter)
{

    int i = 0, int_choice;

    printf("Input item number:");
    scanf("%d", &int_choice);

    for (i = 0; i<int_counter; i++)
    {
        if (int_counter != 0)
        {
            printf("Input new item:");
            gets(num1[i].ItemName);
            FLUSH;
            printf("Input new item price:");
            scanf("%f", &(num1[i]).ItemPrice);
        }
        else
        {
            printf("\nThere is no existing item...");
            getch();
        }
        return;
    }
}
void getItemSales(ITEM num1[], int int_counter)
{
    int i = 0;
    int x = 0;
    int int_choice = 0;

    if (int_counter != 0)
    {
        printf("\nEnter item number: ");
        scanf("%d", &int_choice);

        while ((i<int_counter) && (x == 0))
        {
            if (int_counter != 0)
                x = 1;
            i++;
        }
        i--;

        if (x == 1)
        {
            printf("\nEnter Quantity: ");
            scanf("%d", &int_choice);
            if (int_choice == 0)
            {
                printf("\nThe Quantity does not exist");
                getch();
            }
            else if (int_choice <= -1)
            {
                printf("\nThe Quantity is zero");
                getch();
            }
            else if (int_counter != 0)
                num1[i].ItemQuantity = num1[i].ItemQuantity - int_choice;
            else
            {
                printf("\nThe Quantity bought is negative");
                getch();
            }
        }

        else
        {
            printf("\nThere is no existing item...");
            i = 0;
            getch();
        }
    }

    else
    {
        printf("\nEmpty...");
        getch();
    }

    return;
}
void getItemReceipts(ITEM num1[], int int_counter)
{
    int i = 0;
    int x = 0;
    int int_choice = 0;

    if (int_counter != 0)
    {
        printf("\nEnter item number: ");
        scanf("%d", &int_choice);

        while ((i<int_counter) && (x == 0))
        {
            if (int_counter != 0)
                x = 1;
            i++;
        }
        i--;

        if (x == 1)
        {
            printf("\nEnter item name: ");
            puts(num1[i].ItemName);

            printf("\nEnter Quantity: ");
            scanf("%d", &int_choice);

            if (int_choice == 0)
            {
                printf("\nThe Quantity does not exist");
                getch();
            }
            else if (int_choice <= -1)
            {
                printf("\nThe Quantity received is negative");
                getch();
            }
            else if (int_choice >= num1[i].ItemQuantity)
                num1[i].ItemQuantity = num1[i].ItemQuantity + int_choice;
        }

        else
        {
            printf("\nThere is no existing item...");
            i = 0;
            getch();
        }
    }

    else
    {
        printf("\n\Empty...");
        getch();
    }

    return;

}
void displayAllItems(ITEM num1[], int int_counter)
{
    int i = 0;
    int int_choice = 0;


    if (int_counter != 0)
    {
        for (i = 0; i<int_counter; i++)
        {
            printf("\nItem Number:%d", num1[i].ItemNumber);
            printf("\nItem Name:%s", num1[i].ItemName);
            printf("\nItem Quantity:%hd", num1[i].ItemQuantity);
            printf("\nItem Price:%0.2f", num1[i].ItemPrice);
        }
    }
    else
        printf("\nItem does not exist...");
    getch();

    return;
}

编译时出现以下错误

[Linker error] undefined reference to `EditItemInfo(ITEM*, int)'
[Linker error] undefined reference to `Sales(ITEM*, int)'
[Linker error] undefined reference to `GoodReceipts(ITEM*, int)'
[Linker error] undefined reference to `DisplayAllItems(ITEM*, int)'
[Linker error] undefined reference to `DisplayAllItems(ITEM*, int)' </p><p>  ld returned 1 exit status

所以很困惑,我得到了什么错误?

0 个答案:

没有答案