+ 현재 시간 출력
=======================================================================================
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
int main(void){
char time_string[40];
struct timeval now;
struct tm* ptm;
gettimeofday(&now, (struct timezone *) NULL);
ptm = localtime(&now.tv_sec);
strftime (time_string, sizeof (time_string), "%Y-%m-%d %H:%M:%S", ptm);
printf("%s\n", time_string);
return 0;
}
=======================================================================================
'Programming' 카테고리의 다른 글
Shell Script - 슬립 (0) | 2016.09.02 |
---|---|
Linux C - 컴파일시 sa_family_t 못 찾는 에러 발생시 대처법 (0) | 2016.09.02 |
Linux C - 8진수 10진수 16진수 (0) | 2016.09.02 |
Linux C - memset 부하 많이 먹는다. 스트링 초기화 (0) | 2016.09.02 |
Linux C - 파일 입출력 예제 (0) | 2016.09.02 |