物聯網實習 / 1023 - sprintf 練習+time+clock

 

認識sprintf( ) 涵式 Function 

1

 

1

認識 C 語言的 time( )   涵式 

 

1

認識 clock( ) 涵式

http://tw.gitbook.net/c_standard_library/c_function_clock.html

1

1

#include

#include
#include
 
char s[120], i = 0;
 
int main(int argc, char *argv[]) {
 
time_t  t1 = time( NULL ), t2;
clock_t mS;
 
while ( 1 ) {
    t2 = time( NULL ); //Get current time
    mS = clock() ;
if ( t2 > t1 ) {  //2=2Second
t1 = t2;
sprintf( s, "\n\r Hello d=%2X %ld", i, i, mS );
printf( s );
    ++i;
}
}
return 0;
}