[Techtalk] getting the time as a string in c
kclair at gmail.com
Thu Sep 29 05:05:53 EST 2005
I'm trying to convert a simple perl script to c, only learning the
bare minimum of c that i need to. :)
The functions in time.h, however, are proving to be a bit much for me.
Can anyone give me some advice? I'm trying to get the current time
as a string.
What I have is:
int timestrsize = 10; /* max length of time string */
char timeformat = "%c"; /* format for time string */
const struct tm *timeptr;
size_t strftime(timestring, timestrsize, timeformat, timeptr);
gcc is complaining:
program.c: In function `main':
program.c:38: warning: parameter names (without types) in function declaration
I have absolutely no idea what "const struct tm *timeptr" is doing...
the rest of it I think I understand at least somewhat.
I think before I had "char timestring;" instead of "char
*timestring;". When that was the case, gcc didn't complain and the
program compiled, but running it produced a segmentation fault.
More information about the Techtalk