Get Timestamp using c/c++
Function to note: strftime()
#include <stdio.h>
#include <time.h>
char * getConcatTimestamp(){
time_t rawtime;
struct tm * timeinfo;
char *buffer;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
buffer = (char *) malloc( sizeof(char) *30);
strftime (buffer,30,"%Y%m%d%H%M%S",timeinfo);
return buffer;
}
int main(){
char *tstamp = getConcatTimestamp();\
printf("%s", tstamp);
return 0;
}
reference: http://www.cplusplus.com/reference/clibrary/ctime/strftime/
No comments:
Post a Comment