Click here to Skip to main content
15,885,961 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
struct queue{
    int value;
    struct queue *tlink;
    struct queue *blink;
};

typedef struct queue* Q;

void enqueue(Q top, int val, Q bottom=NULL);


error:
expected ‘;’, ‘,’ or ‘)’ before ‘=’ token
void enqueue(Q top, int val, Q bottom=NULL);


What I have tried:

I am trying to initialise a structure pointer variable to default value NULL in function parameter. (Default parameter)
Posted
Updated 25-Dec-17 20:57pm
Comments
Peter_in_2780 26-Dec-17 2:54am    
The C language (unlike many of its derivatives) doesn't do default parameters. You'll need to find another way to express what you want to achieve.

1 solution

C doesn't have any concept of default parameters, so you pretty much can't do that.


(Which is a lie-to-children, becuase you can, but it's horribly complicated and messy: C default arguments - Stack Overflow[^] - see BK's solution, which TBH is worse than the original problem from a maintenance POV).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900