반응형
time
1.소스
#include <stdio.h> #include <time.h> #define SIZE 256 int main( int argc , char ** argv ) { char buf[256]; struct tm *loctime; time_t curtime = time(NULL); loctime = localtime(&curtime); fputs( asctime(loctime ) , stdout ); strftime(buf, SIZE , "today is %A, %B %d \n", loctime ); fputs( buf , stdout ); strftime(buf, SIZE, "the time is %I:%M %p \n", loctime ); fputs( buf , stdout); return 0; }
결과
hacker@ubuntu:~/c$ hacker@ubuntu:~/c$ hacker@ubuntu:~/c$ hacker@ubuntu:~/c$ gcc -o time1 time1.c hacker@ubuntu:~/c$ hacker@ubuntu:~/c$ ./time1 Tue Aug 2 21:05:34 2016 today is Tuesday, August 02 the time is 09:05 PM hacker@ubuntu:~/c$ hacker@ubuntu:~/c$
반응형
'C 언어' 카테고리의 다른 글
memory layout( for ubuntu 64bit) (0) | 2016.08.03 |
---|---|
bi-directional sweep sort (0) | 2016.08.03 |
[c] printf (0) | 2016.08.03 |
PHP_STRLCPY (0) | 2016.07.27 |
매크로 사용하기(php소스 쪼개서 사용하기) (0) | 2016.07.21 |