C:使用结构和指针,错误:一元'*'的无效类型参数

Gau*_*tam 2 c struct pointers

我正在研究ac程序,这是我正在使用的结构

struct EngineParts{

    int serial_number;
    unsigned int year_of_manufacture;
    unsigned int quantity;
    char *material;

}*Eparts;
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

`Automobile.c:79:5: error: invalid type argument of unary ‘*’ (have ‘unsigned int’)` 

`Automobile.c:80:5: error: invalid type argument of unary ‘*’ (have ‘int’)` 

`Automobile.c:81:5: error: invalid type argument of unary ‘*’ (have ‘unsigned int’)`
Run Code Online (Sandbox Code Playgroud)

在这三行中

 *new->quantity = quantity;
 *new->serial_number = serial_number;
 *new->year_of_manufacture = year_of_manufacture;
Run Code Online (Sandbox Code Playgroud)

这是完整的实现

void automobile_add_part(const int serial_number,
        const unsigned int year_of_manufacture,
        const unsigned int quantity , 
        const char *material){
    /*
     * Store the address to the latest part
     */
   struct EngineParts *new ;
   new = (Eparts+available_number_of_parts);

    // Copying a String is a little bit complicated
    // First memory is allocated for the string 
    *new->material = (char *)calloc(strlen(material),sizeof(char));
    //Then the string is copied
    strcpy((char *)*new->material,material);    

    *new->quantity = quantity;
    *new->serial_number = serial_number;
    *new->year_of_manufacture = year_of_manufacture;

    available_number_of_parts++;
}
Run Code Online (Sandbox Code Playgroud)

PS:我查看了以下问题,

错误:'unary*'的无效类型参数(有'int')

无效的类型参数 - > C结构

但他们似乎没有帮助我.

有关如何解决问题的任何建议?

mil*_*ose 6

->运营商已经取消引用指针为您服务.

new->serial_number相当于(*new).serial_number,两者看起来都像你想要的那样.