Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C¡¢C++ÖеÄÈÕÆÚºÍʱ¼ä time_tÓëstruct tmת»»

Ò»£®¸ÅÄî
Coordinated Universal Time£¨UTC£©£ºÐ­µ÷ÊÀ½çʱ£¬ÓÖ³ÆΪÊÀ½ç±ê׼ʱ¼ä£¬Ò²¾ÍÊÇ´ó¼ÒËùÊìÖªµÄ¸ñÁÖÍþÖαê׼ʱ¼ä£¨Greenwich Mean Time£¬GMT£©¡£±ÈÈ磬ÖйúÄڵصÄʱ¼äÓëUTCµÄʱ²îΪ+8£¬Ò²¾ÍÊÇUTC+8¡£ÃÀ¹úÊÇUTC-5¡£
Calendar Time£ºÈÕÀúʱ¼ä£¬ÊÇÓÓ´ÓÒ»¸ö±ê׼ʱ¼äµãµ½´ËʱµÄʱ¼ä¾­¹ýµÄÃëÊý”À´±íʾµÄʱ¼ä¡£Õâ¸ö±ê׼ʱ¼äµã¶Ô²»Í¬µÄ±àÒëÆ÷À´Ëµ»áÓÐËù²»Í¬£¬µ«¶ÔÒ»¸ö±àÒëϵͳÀ´Ëµ£¬Õâ¸ö±ê׼ʱ¼äµãÊDz»±äµÄ£¬¸Ã±àÒëϵͳÖеÄʱ¼ä¶ÔÓ¦µÄÈÕÀúʱ¼ä¶¼Í¨¹ý¸Ã±ê׼ʱ¼äµãÀ´ºâÁ¿£¬ËùÒÔ¿ÉÒÔ˵ÈÕÀúʱ¼äÊÇ“Ïà¶Ôʱ¼ä”£¬µ«ÊÇÎÞÂÛÄãÔÚÄÄÒ»¸öʱÇø£¬ÔÚͬһʱ¿Ì¶Ôͬһ¸ö±ê׼ʱ¼äµãÀ´Ëµ£¬ÈÕÀúʱ¼ä¶¼ÊÇÒ»ÑùµÄ¡£
epoch£ºÊ±¼äµã¡£Ê±¼äµãÔÚ±ê×¼C/C++ÖÐÊÇÒ»¸öÕûÊý£¬ËüÓôËʱµÄʱ¼äºÍ±ê׼ʱ¼äµãÏà²îµÄÃëÊý£¨¼´ÈÕÀúʱ¼ä£©À´±íʾ¡£
clock tick£ºÊ±ÖÓ¼Æʱµ¥Ôª£¨¶ø²»°ÑËü½Ð×öʱÖӵδð´ÎÊý£©£¬Ò»¸öʱÖÓ¼Æʱµ¥ÔªµÄʱ¼ä³¤¶ÌÊÇÓÉCPU¿ØÖƵġ£Ò»¸öclock tick²»ÊÇCPUµÄÒ»¸öʱÖÓÖÜÆÚ£¬¶øÊÇC/C++µÄÒ»¸ö»ù±¾¼Æʱµ¥Î»¡£
¶þ£® ¼Æʱ
1.    clock: C/C++ÖеļÆʱº¯ÊýÊÇclock()£¬¶øÓëÆäÏà¹ØµÄÊý¾ÝÀàÐÍÊÇclock_t¡£ÔÚMSDNÖУ¬²éµÃ¶Ôclockº¯Êý¶¨ÒåÈçÏ£º
clock_t clock( void );
·µ»Ø£º´Ó“¿ªÆôÕâ¸ö³ÌÐò½ø³Ì”µ½“³ÌÐòÖе÷ÓÃclock()º¯Êý”ʱ֮¼äµÄCPUʱÖÓ¼Æʱµ¥Ôª£¨clock tick£©Êý¡£
clock_t£ºÊÇÓÃÀ´±£´æʱ¼äµÄÊý¾ÝÀàÐÍ£¬ÔÚtime.hÎļþÖУ¬ÎÒÃÇ¿ÉÒÔÕÒµ½¶ÔËüµÄ¶¨Ò壺
#ifndef _CLOCK_T_DEFINED
typedef long clock_t;
#define _CLOCK_T_DEFINED
#endif
2. CLOCKS_PER_SEC       ÔÚtime.hÎļþÖУ¬»¹¶¨ÒåÁËÒ»¸ö³£Á¿CLOCKS_PER_SEC£¬ËüÓÃÀ´±íʾһÃëÖÓ»áÓжàÉÙ¸öʱÖÓ¼Æʱµ¥Ôª£¬Æ䶨ÒåÈçÏ£º
#define CLOCKS_PER_SEC ((clock_t)1000)
¿ÉÒÔ¿´µ½¿ÉÒÔ¿´µ½Ã¿¹ýǧ·ÖÖ®Ò»Ã루1ºÁÃ룩£¬µ÷ÓÃclock£¨£©º¯Êý·µ»ØµÄÖµ¾Í¼Ó1¡£ÏÂÃæ¾Ù¸öÀý×Ó£¬Äã¿ÉÒÔʹÓù«Ê½clock()/CLOCKS_PER_SECÀ´¼ÆËãÒ»¸ö½ø³Ì×ÔÉíµÄÔËÐÐʱ¼ä£º
void elapsed_time()
{
printf("Elapsed time:%u secs.\n",clock()/CLOCKS_PER_SEC);
}
3.    ÓÃclock¼Æʱ
µ±È»£¬ÄãÒ²¿ÉÒÔÓÃclockº¯ÊýÀ´¼ÆËãÄãµÄ»úÆ÷ÔËÐÐÒ»¸öÑ­»·»òÕß´¦ÀíÆäËüʼþµ½µ×»¨Á˶àÉÙʱ¼ä£º
·½·¨1£º
#include “stdio.h”
#include “stdlib.h”
#include “time.h”
int main( void )
{
   long   &n


Ïà¹ØÎĵµ£º

WindowsÏÂÓÃEclipse´î½¨C/C++¿ª·¢»·¾³

±¾Îļٶ¨ÄãÒѾ­ÊìϤJava,EclipseµÄ°²×°,²¢ÄÜ˳ÀûÆô¶¯ºÍÔËÐÐEclipse.´ËÍâÒòΪ¸÷Èí¼þ°æ±¾ÔÚ²»¶Ï¸üУ¬ÓÐЩµØ·½¿ÉÄܲ»×¼È·£¬ÒÔ×îеġ¢Ô­ÎÄ×ÊÁÏΪ׼¡£ 
¾àÉÏÒ»´ÎдºÍµ÷C++³ÌÐò£¬ÒѾ­5¡¢6ÄêÁË£¬¹âÒõÜóÜÛËêÔÂÎÞÇ飬ÏÖÔÚÔÙÖØÐÂÊ°ÆðÀ´£¬ºÜ¶à¶«Î÷¶¼Òª´ÓÍ·À´¡£WindowsÏÂC/C++µÄIDEÓкܶ࣬ÎÒÖªµÀµÄ¾ÍÓÐMS Visual Studio£¬Borla ......

ÓÃEclipse+Mingw+gdb×齨C/C++¿ª·¢»·¾³

1 ÏÂÔØ°²×°jre£¬Eclipse±¾ÉíÊÇJava³ÌÐò£¬ÔËÐеÄʱºòÐèÒªjre¡£
2 ÏÂÔØEclispe for C/C++£¬½âѹµ½ÈÎÒâλÖá£
3 ÏÂÔØMingw°²×°³ÌÐò£¬ÔËÐУ¬Ñ¡ÔñÐèÒªµÄ×é¼þ£¬ÎÒÑ¡ÔñÁËg++±àÒëÆ÷ºÍMakefile¹¤¾ß£¬Ëü»á×Ô¶¯ÏÂÔØ°²×°¡£
4 ÏÂÔØ°²×°gdbµ½MingwµÄ°²×°Ä¿Â¼£¬gdbµÄbinºÍincludeĿ¼»áºÍMingwµÄͬÃûĿ¼ºÏ²¢µÄ¡£
ÏÂÃ濪ʼÅäÖÃEclipse¡ ......

LinuxÇý¶¯¿ª·¢Ö®S3C2440°´¼üµãÁÁLED

ÎÄռǼÁË×÷ÕßÔÚS3C2440¿ª·¢°åÉÏʵÏÖ°´¼üµãÁÁLEDÇý¶¯¿ª·¢µÄÏêϸ¹ý³Ì£¬»¹¼Ç¼ÁËһЩÈÝÒ׳öÏֵĴíÎó£¬ÒÔ¼°Ôõô½â¾öÕâЩ´íÎó¡£
Ò»¡¢Çý¶¯¿ª·¢Á÷³Ì
       LinuxÇý¶¯¿ª·¢²»Í¬ÓÚÓ¦ÓóÌÐòµÄ¿ª·¢¡£Çý¶¯¿ª·¢ÊÇÖ±½ÓºÍÓ²¼þ´ò½»µÀµÄ£¬Í¨¹ý¶ÔÓ²¼þµÄ²Ù×÷¸øÓ¦ÓóÌÐòÌṩһЩ½Ó¿Úº¯Êý£¬Ê¹µÃÓ¦ÓóÌÐòÄܹ»&l ......

[C/C++]C++Ï»ù±¾ÀàÐÍËùռλÊýºÍÈ¡Öµ·¶Î§

Ô­ÎÄ£ºhttp://hi.baidu.com/magicdemon/blog/item/821b2e22d7df494cad34debd.html
C++Ï»ù±¾ÀàÐÍËùռλÊýºÍÈ¡Öµ·¶Î§£º
·ûºÅÊôÐÔ      ³¤¶ÈÊôÐÔ      »ù±¾ÐÍ      ËùռλÊý      È¡Öµ·¶Î§   ÊäÈë·û¾ÙÀý&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ