I have this function which is supposed to set a certain time format to the given char*:
static void timeStamp(char* time)
{
time(&strTime);<---ERROR
curTime = std::localtime(&strTime);
strftime(time, 8, "%H:%M::", curTime);
}
strTime and curTime were declared like this:
tm* curTime;
time_t strTime;
but for some reason i get:
called object type 'char*' is not a function or function pointer
on the marked place.
any idea why?
im using xCode by the way.
Your function parameter time
is a pointer to a char.
However, in your function body, you're trying to treat it if it were a function that you can call. That's what the error is saying...
the object of type
char *
is not a function or a function pointer [therefore, I can't call it!]
Essentially, you've hidden the time
function by having a local variable of the same name. I'd recommend changing your function parameter's name.
The function parameter
static void timeStamp(char* time)
{
time(&strTime);<---ERROR
// ...
}
shadows the time()
function. Rename the parameter.
static void timeStamp(char* time)
here, this char* time
parameter is hidding the function time()
.you will need to rename it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With