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
Ïà¹ØÎĵµ£º
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( ......
12.1 λÔËËã·û£ÃÓïÑÔÌṩÁËÁùÖÖλÔËËã·û£º
& °´Î»Óë
| °´Î»»ò
^ &nb ......
±àÒëµÄ¸ÅÄ±àÒë³ÌÐò¶ÁÈ¡Ô´³ÌÐò£¨×Ö·ûÁ÷£©£¬¶ÔÖ®½øÐдʷ¨ºÍÓï·¨µÄ·ÖÎö£¬½«¸ß¼¶ÓïÑÔÖ¸Áîת»»Îª¹¦ÄܵÈЧµÄ»ã±à´úÂ룬ÔÙÓÉ»ã±à³ÌÐòת»»Îª»úÆ÷ÓïÑÔ£¬²¢ÇÒ°´ÕÕ²Ù×÷ϵͳ¶Ô¿ÉÖ´ÐÐÎļþ¸ñʽµÄÒªÇóÁ´½ÓÉú³É¿ÉÖ´ÐгÌÐò¡£
±àÒëµÄÍêÕû¹ý³Ì£ºCÔ´³ÌÐò££>Ô¤±àÒë´¦Àí(.c)££>±àÒë¡¢ÓÅ»¯³ÌÐò£¨.s¡¢.asm£©££>»ã± ......
¼ì²éÄں˲ÎÊý
ÕýÔÚ¼ì²é semmsl=250; ÒÑ·¢ÏÖ semmsl=250¡£ ͨ¹ý
ÕýÔÚ¼ì²é semmns=32000; ÒÑ·¢ÏÖ semmns=32000¡£ ͨ¹ý
ÕýÔÚ¼ì²é semopm=100; ÒÑ·¢ÏÖ semopm=32¡£ ʧ°Ü <<<<
ÕýÔÚ¼ì²é semmni=128; ÒÑ·¢ÏÖ semmni=128¡£ ͨ¹ý
ÕýÔÚ¼ì²é shmmax=536870912; ÒÑ·¢ÏÖ shmmax=33554432¡£ ʧ°Ü <<<< ......