无法编译 : Nested Structures

标签 c struct nested

所以我的程序无法编译,我认为这是因为我使用了嵌套结构。它说我需要检查我的图书馆包括。问题是,我不知道要包括什么:s 所以无论如何,请帮助我! :D

存在三个错误:

> [Linker error] PROJECT.o:PROJECT.c:(.text+0x47a): undefined reference to `place' 
   collect2: ld returned 1 exit status 
   [Error] [PROJECT.exe] Error 1 (if this is the only error: please check your library includes) 

这是我的代码:

typedef struct{
    int thick, thin;
    int reds, bbqs, creams, pestos;
    float pepperoni, pork, mball, tuna, chicken, ham, bacon, shrimp;
    float mozz, cheddar, ricotta;
    float bellpep, redon, tom, olive, pine, mush;
}TOPP;

typedef struct{
    char name[128], address[128];
    double contact;
    int delivered;
}CUSDET;
typedef struct{
    int pres;
    int qtyordered;
    char name[128];
    char desc[128];
    float price10, price14, price18;
}PIZZA;
PIZZA prem[50]={0,0,'\0','\0',0,0,0};
typedef struct{
    float total, totalsum;
    TOPP myo10[10], myo14[10], myo18[10];
    CUSDET cus; 
}ORDZ;
ORDZ temp, *pt;
ORDZ order[90], *pol;
TOPP *pm;
CUSDET *pc;
PIZZA *ppm;`

然后我在这个函数中使用了那些:

void cusdetails(){
pc=&temp.cus;
int a=0, a1;
do{
 system("cls");
    printf("RMR PIZZA - Customer Page.\n\n");
    printf("Welcome to RMR PIZZA!\n");
    printf("Enter Name: ");
    scanf(" %[^\n]s", &pc->name);
    printf("Enter Address: ");
    scanf(" %[^\n]s", &pc->address);
    printf("Enter Contact Number: ");
    scanf("%lf", &pc->contact);
    printf("\n\n Your details are as follows:\n\n");
    printf("Name: %s\n", pc->name);
    printf("Address: %s\n", pc->address);
    printf("Contact Number: %0.0lf\n", pc->contact);
}while(a==2);   
}

最佳答案

您的错误与嵌套结构无关。错误:

Linker error] PROJECT.o:PROJECT.c:(.text+0x47a): undefined reference to `place' 
collect2: ld returned 1 exit status 

告诉您它找不到上面未显示的代码的某些部分中使用的命令/函数 place。您很可能已经定义了一个名为 place 的函数,并且在定义出现之前在您的代码中使用了它(或者它是来自您忘记包含头文件的其他库(或文件)的函数为了)。无论哪种方式,您都在尝试使用 place 并且链接器告诉您它不知道您在说什么。显示引用 place 的代码以获得更多帮助。

关于无法编译 : Nested Structures,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25342937/

相关文章:

c - 如何在 C 中拥有包含多种类型对象或函数的数组

arrays - 使用 Struct 的 Encodable 协议(protocol)解码 2D 多边形坐标

c++结构数组 - "This declaration has no storage class or type specifier"

java - 在 Android 中使用 XMLPullParser 的 XML 嵌套标签有困难

C 使用 strcpy 替换二维字符数组中的字符串问题

jquery - 奇怪的 jQuery 问题 - 对 C 程序的 Ajax 请求不太工作

这个递归函数可以在没有 `trav` 指针的情况下工作吗

c - LLVM IR 限制

ruby-on-rails - 删除浅嵌套 Comment 类返回错误 "Couldn' t 查找没有 ID 的 Comment”(Rails)

swift - 在另一个自定义 UIView 中设置/更改嵌套自定义 UIView 的变量