将值分配给数组内结构的结构成员

时间:2014-12-01 16:00:57

标签: c arrays linked-list structure

我正在尝试使用数组,结构和链表制作清单。 我有一个AddNewStock函数,它是更大代码的一部分。调用时,它将获取类别,供应商和产品名称的值。我在输入类别时遇到运行时错误。我已经尝试了一切,但我仍然输了。任何输入都很好

struct ProductListTag
{
    string15 Supplier; 
    string15 Product;
    struct ProductListTag *pLink;
};

typedef struct
{
    string15 Category; 
    struct ProductListTag *ProdList;

} StockInfo;

typedef StockInfo Stock[10];`

/*numCat is number of Categories, assume its a 0*/

void AddNewStock(Stock arrStock, int * numCat)
{   
    printf("What is the product category? ");
    fgets(arrStock[*numCat].Category, LEN15 ,stdin);
    printf("\nWho is the Supplier? ");  
    fgets(arrStock[*numCat].ProdList->Supplier,LEN15,stdin);
    printf("%s",arrStock[*numStock].ProdList->Supplier);
    printf("\nWhat is the product? ");
    fgets((arrStock[*numCat].ProdList->Product),LEN15,stdin);         
}

0 个答案:

没有答案