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

CÖеĿÕ


1.   ʲôÊÇ¿ÕÖ¸Õë³£Á¿£¨null pointer constant£©?
[ 6.3.2.3-3] An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
ÕâÀï¸æËßÎÒÃÇ£º0¡¢0L¡¢'\0'¡¢3 - 3¡¢0 * 17 £¨ËüÃǶ¼ÊÇ“integer constant expression”£©ÒÔ¼° (void*)0 £¨tyc£ºÎÒ¾õµÃ(void*)0Ó¦¸ÃËãÊÇÒ»¸ö¿ÕÖ¸Õë°É£¬¸üÇ¡µ±Ò»µã£©µÈ¶¼ÊÇ¿ÕÖ¸Õë³£Á¿£¨×¢Òâ (char*) 0 ²»½Ð¿ÕÖ¸Õë³£Á¿£¬Ö»ÊÇÒ»¸ö¿ÕÖ¸ÕëÖµ£©¡£ÖÁÓÚϵͳѡȡÄÄÖÖÐÎʽ×÷Ϊ¿ÕÖ¸Õë³£Á¿Ê¹Óã¬ÔòÊÇʵÏÖÏà¹ØµÄ¡£Ò»°ãµÄ C ϵͳѡÔñ (void*)0 »òÕß 0 µÄ¾Ó¶à£¨Ò²Óиö±ðµÄÑ¡Ôñ 0L£©£»ÖÁÓÚ C++ ϵͳ£¬ÓÉÓÚ´æÔÚÑϸñµÄÀàÐÍת»¯µÄÒªÇó£¬void* ²»ÄÜÏó C ÖÐÄÇÑù×ÔÓÉת»»ÎªÆäËüÖ¸ÕëÀàÐÍ£¬ËùÒÔͨ³£Ñ¡ 0 ×÷Ϊ¿ÕÖ¸Õë³£Á¿£¨tyc: C++±ê×¼ÍƼö£©£¬¶ø²»Ñ¡Ôñ (void*)0¡£
2.   ʲôÊÇ¿ÕÖ¸Õ루null pointer£©?
[6.3.2.3-3] If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.
Òò´Ë£¬Èç¹û p ÊÇÒ»¸öÖ¸Õë±äÁ¿£¬Ôò p = 0;¡¢p = 0L;¡¢p = '\0';¡¢p = 3 - 3;¡¢p = 0 * 17; ÖеÄÈκÎÒ»ÖÖ¸³Öµ²Ù×÷Ö®ºó£¨¶ÔÓÚ C À´Ëµ»¹¿ÉÒÔÊÇ p = (void*)0;£©£¬ p ¶¼³ÉΪһ¸ö¿ÕÖ¸Õ룬ÓÉϵͳ±£Ö¤¿ÕÖ¸Õë²»Ö¸ÏòÈκÎʵ¼ÊµÄ¶ÔÏó»òÕߺ¯Êý¡£·´¹ýÀ´Ëµ£¬ÈκζÔÏó»òÕߺ¯ÊýµÄµØÖ·¶¼²»¿ÉÄÜÊÇ¿ÕÖ¸Õë¡££¨tyc: ±ÈÈçÕâÀïµÄ(void*)0¾ÍÊÇÒ»¸ö¿ÕÖ¸Õë¡£°ÑËüÀí½âΪnull pointer»¹ÊÇnull pointer constant»áÓÐ΢ÃëµÄ²»Í¬£¬µ±È»Ò²²»ÊǽôÒªÁË£©
3.   ʲôÊÇ NULL£¿
[6.3.2.3-Footnote] The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant
¼´ NULL ÊÇÒ»¸ö±ê×¼¹æ¶¨µÄºê¶¨Ò壬ÓÃÀ´±íʾ¿ÕÖ¸Õë³£Á¿¡£Òò´Ë£¬³ýÁËÉÏÃæµÄ¸÷ÖÖ¸³Öµ·½Ê½Ö®Í⣬»¹¿ÉÒÔÓà p = NULL; À´Ê¹ p ³ÉΪһ¸ö¿ÕÖ¸Õë¡££¨tyc£ººÜ¶àϵͳÖеÄʵÏÖ£º#define NULL (void*)0£¬ÓëÕâÀïµÄ“a null pointer constant”²¢²»ÊÇÍêÈ«Ò»Öµģ©
4.   ¿ÕÖ¸Õ루null pointer£©Ö¸ÏòÁËÄÚ´æµÄʲôµØ·½£¨¿ÕÖ¸ÕëµÄÄÚ²¿ÊµÏÖ£©£¿
±ê×¼²¢Ã»ÓжԿÕÖ¸ÕëÖ¸ÏòÄÚ´æÖеÄʲôµØ·½ÕâÒ»¸öÎÊÌâ×÷³ö¹æ¶¨£¬Ò²¾ÍÊÇ˵ÓÃÄĸö¾ßÌåµÄµØÖ·Öµ£¨0x0 µØÖ·»¹ÊÇijһÌض¨µØÖ·£©±íʾ¿ÕÖ¸ÕëÈ¡¾öÓÚϵͳµÄʵÏÖ¡£ÎÒÃdz£¼ûµÄ¿ÕÖ¸ÕëÒ»°ãÖ¸Ïò 0 µØÖ·£¬¼´¿ÕÖ¸ÕëµÄÄÚ²¿ÓÃÈ« 0


Ïà¹ØÎĵµ£º

CÓïÑÔÁ¬½ÓMySQLÊý¾Ý¿â

Ç°¼¸Ì칫˾ÈÃÎÒ×öCÓïÑÔºÍMySQLÊý¾Ý¿âµÄ½»»¥²Ù×÷£¬·ÑÁ˾ÅÅ£¶þ»¢Ö®Á¦Ö®ºó×ÜËã×ö³öÀ´ÁË£¬½ñÌìÌصذÑÔ´´úÂëÌù³öÀ´¹©´ó¼Òѧϰ£»ÈçÓÐÈËÏëÒª´ò°üÏîÄ¿¿ÉÒÔ¼ÓÎÒQQ260990509,×¢Ã÷¼¼Êõ½»Á÷£¬¼´¿É»ñµÃ´ò°üÖ®ºóµÄÏîÄ¿£¡
#if defined(_WIN32) || defined(_WIN64)  //ΪÁËÖ§³Öwindowsƽ̨ÉϵıàÒë
#include <windows.h>
#end ......

¹ØÓÚCµÄ0x8±¾¡°¾­Ê顱£ÛǶÈëʽ±Ø¶Á£Ý

ÔÚµ±½ñǶÈëʽ“ÎäÁÖ”ÖУ¬Á÷´«×ż¸±¾ÈËÈ˶¼Ïë͵ѧ¼¸ÕеÄCÓïÑÔµÄÎ书Ãؼ®¡£ÕâЩÃؼ®¶¼ÊÇ¿õÊÀÎäѧÆæ²ÅºÄ¾¡±ÏÉú¾«Á¦ËùÖø£¬²¿·ÖÃؼ®Á÷¾­ÊýÊ®ÔØÈÔ¾­¾Ã²»Ë¥£¬ÈÃËüµÄÎÞÊýʵϰÕßÊÜÒæ·Ëdz¡£¡¡¡¡½ñÌ죬³ÐÃÉÎäÁÖ´ó»áËùÍÏ£¬ÔÚÕ⹫²¼Õ⼸±¾¹ØÓÚCµÄ“¾­Ê锣¬Èøü¶àÈËʵϰ֮£¬Á·¾ÍÒ»Éí¾øÊÀµÄǶÈëʽCÓïÑԺù¦·ò¡£Î书à ......

ǶÈëʽC±ÊÊÔ£¡

1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³£Êý±í´ïʽµÄÖµ£¬Òò´Ë£¬Ö±½Óд³öÄãÊÇÈçºÎ¼ÆËãÒ»ÄêÖÐÓж ......

C/C++ʱ¼äº¯Êý

clock()·µ»Øclock_tÀàÐÍ£»
ÔÚtime.hÍ·ÎļþÖУ¬¶¨ÒåÁË typedef long clock_t
clock()ÊÇÓÃÀ´¼ÆËãÁ½¸öʱ¼äµãÖ®¼äµÄʱ¼ä¼ä¸ô¡£ÈçϳÌÐò£º
#include <stdio.h>
int main()
{
 int i = 0;
 clock_t start_time, end_time;
 start_time = clock(); //¿ªÊ¼¼Æʱ, start_time = 0
 
 while( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ