밀리초를 구현하는 방법
//-------------------------------------------------------------------------------- //다음과 같이 하면 됩니다. /* FTIME.C: This program uses _ftime to obtain the current * time and then stores this time in timebuffer. */ #include <stdio.h> #include <sys/timeb.h> #include <time.h> void main( void ) { struct _timeb timebuffer; char *timeline; _ftime( &timebuffer ); timeline = ctime( & ( timebuffer.time ) ); printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] ); } //Output //The time is Tue Mar 21 15:26:41.341 1995
현재 시간을 읽어 화면에 표시하는 것을 하고 있는데, 년월일 시분초 등을 나타내고 1000분의 1초(milliseconds) 단위도 표현하고 싶은데 어떻게 해야 하는지 방법을 알려주세요.
//-------------------------------------------------------------------------------- //다음과 같이 하면 됩니다. /* FTIME.C: This program uses _ftime to obtain the current * time and then stores this time in timebuffer. */ #include <stdio.h> #include <sys/timeb.h> #include <time.h> void main( void ) { struct _timeb timebuffer; char *timeline; _ftime( &timebuffer ); timeline = ctime( & ( timebuffer.time ) ); printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] ); } //Output //The time is Tue Mar 21 15:26:41.341 1995