Youssef Khloufi Youssef Khloufi - 9 days ago 6
C Question

error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token

I get this error in a C header file in this line :

char * getFechaHora(time_t & tiempoPuro);


In a C source code file i am including the header file and giving the function an implementation

char * getFechaHora(time_t &tiempoPuro){...}


also in my header file i am including correctly the "time.h" library.

Answer

In C, if char * getFechaHora, this is your function and the two (time_t & tiempoPuro) are arguments you should declare the function as:

char * getFechaHora(time_t, tiempoPuro);

else if the second is a variable, declare as

char * getFechaHora(time_t *tiempoPuro);
Comments