I am new to C programming and I would like some help with a simple task.
So I have this function:
char *time2str(time_t time) {
static_char *str_fmt = "%02d/%02d/%4d %02d:%02d";
char *time_s = "";
return time_s;
}
What I would like to do is get in DD/MM/YYYY HH:MM format the time and store it in time_s variable so that I can return it. My problem is that I cannot figure out how to format the string and store it WITHOUT printing it. All I have found so far is the sprint method that actually prints the formatted string when storing it too, which is not what I want.
In a few words, I would just like the time from time_t time in the format I mentioned stored in time_s.
Sorry if I didn't explain everything properly but I'm new in C programming.