简体   繁体   English

未解决的外部符号,致命错误LNK1120

[英]Unresolved external Symbol, fatal error LNK1120

I'm trying to create a program that stores an inventory of items into a dynamic array, while keeping track of the itemID, a description of the item, quantity and price. 我正在尝试创建一个程序,将项目库存存储到动态数组中,同时跟踪itemID,项目描述,数量和价格。 Only problem is I get an unresolved external symbol error 唯一的问题是我得到一个未解决的外部符号错误

"struct inventory item * * list", fatal error LNK1120. 

Any idea what the problem is or how to resolve it? 知道问题是什么或如何解决它?

#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
#include <vector>

using namespace std;

struct inventoryitem{
    char itemid[7];
    string itemDesc;
    int quantity;
    float price;
    float retailprice;
};

inventoryitem *list[];
void add();
void edit();
void search();
void display();
void remove();
void textfile();

int main(){//main menu
    while(true){
        cout << "\nInventory Database Manager\n";
        cout << "_____________________________\n";
        cout << "What would you like to do?\n";
        cout << "1) Add item to database\n";
        cout << "2) Edit item in database\n";
        cout << "3) Search the database for an item\n";
        cout << "4) Delete an item in database\n";
        cout << "5) Display all items\n";
        //cout << "6) Exit program\n";
        cout << "Input command (1-5)\n\n";
        int input;
        cin >> input;
        switch(input){
            case 1: add();
            case 2: edit();
            case 3: search();
            case 4: remove();
            case 5: display();
            default : cout << "\nError, invalid input, try again";
        }
    }
}

int inc = 0;

void add(){
    inventoryitem item;
    cout << "\nEnter Item ID (3 letters followed by 4 digits)\n";
    cin >> list[inc]->itemid;
    for(int x = 0; x < 6; x++){//validates the item ID, checks if the first 3 digits are numbers first, then the next 4 
        if(x < 2){
            if(isalpha(item.itemid[x])){
                //do nothing
            }
            else{
                cout << "Error, itemID is 3 letters followed by 4 digits";
                break;
            }
        }
        if(x > 2){
            if(isdigit(item.itemid[x])){
                //do nothing
            }
            else{
                cout << "Error, itemID is 3 letters followed by 4 digits";
                break;
            }
        }
    }
    cout << "Enter the item's description\n";
    cin >> list[inc]->itemDesc;
    cout << "Enter the quantity of item\n";
    cin >> list[inc]->quantity;
    cout << "Enter the price of the item\n";
    cin >> list[inc]->price;
    cout << "Enter the retail price of the item\n";
    cin >> list[inc]->retailprice;


}
void edit(){}
void search(){}
void display(){}
void remove(){}
void textfile(){}

Clang issues a more useful compiler error for this line: Clang为此行发出了更有用的编译器错误:

inventoryitem *list[];

definition of variable with array type needs an explicit size or an initializer 具有数组类型的变量的定义需要显式大小或初始化程序

In C++, you would be better to use one of the many containers available to you. 在C ++中,您最好使用可用的众多容器之一。 Eg: 例如:

std::list<inventoryitem>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误LNK1120:1个未解决的外部零件 - fatal error LNK1120: 1 unresolved externals 严重错误LNK1120:8个未解决的外部零件 - fatal error LNK1120: 8 unresolved externals “错误LNK2019:未解决的外部致命故障”和“错误LNK1120:1未解决的外部致命故障” - “error LNK2019: unresolved external fatal” and “error LNK1120: 1 unresolved externals” Visual Studio 2013错误LNK1120:1未解决的外部和错误LNK2019:未解决的外部符号 - visual studio 2013 error LNK1120: 1 unresolved externals and error LNK2019: unresolved external symbol 错误LMK2019:未解决的符号/致命错误LNK1120:1个未解析的外部 - error LMK2019: unresolved symbol / fatal error LNK1120: 1 unresolved externals 链接器错误:致命错误LNK1120:1个未解决的外部组件 - Linker error: fatal error LNK1120: 1 unresolved externals Visual C致命错误LNK1120:1个未解决的外部组件 - Visual C fatal error LNK1120: 1 unresolved externals OpenSSL致命错误LNK1120:3个未解决的外部组件 - OpenSSL fatal error LNK1120: 3 unresolved externals 致命错误LNK1120:C ++中1个未解决的外部组件 - fatal error LNK1120: 1 unresolved externals in c++ C++ 致命错误 LNK1120:1 个未解决的外部 - C++ Fatal Error LNK1120: 1 unresolved externals
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM