简体   繁体   中英

struct node * void expected identifier or '(' before 'void'

There is a function like this. I took this error expected identifier or '(' before 'void' How to solve this problem? Thank you.

struct node * void ekleSirali(struct node * r,int x){
     if(r==NULL){
        r=(struct node *)malloc(sizeof(struct node));
        r->next=NULL;
        r->x =x;     
        return r;  
     }

I don't know whether I should write struct.

The type specifier void is redundant and invalid in this context. Write

struct node * ekleSirali(struct node * r,int x){

That is the function return type can be either void (if the function returns nothing) or struct node * (if the function returns a pointer of the type struct node * as shown in your code snippet).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM