I have this code for create timestamp:
the code is in C.
void timestamp()
{
time_t ltime; /* calendar time */
ltime=time(NULL); /* get current cal time */
printf("%s Something\n",asctime( localtime(<ime) ) );
}
why is the text “Something” on the next line? What can I do to have it on same line?
I’m confused because I don’t have \n after %s, so it should be on same line, but it isn’t.
Thx.
The
asctimespecification (C99 §7.23.3.1/2) reads as follows:Note the newline character at the end of the time.
If you do not want the time followed by a newline, you need to remove the newline yourself or use another library function, like
strftime.