Hidden Tricks (C)(091121)
ÇëÔËÐÐÏÂÃæµÄ´úÂ룬¹Û²ì½á¹û£¬ÓÐÈË˵ÔõôÊÇËÀÑ»·£¬ÄãͬÒâÂð£¿ÎªÊ²Ã´£¿
#include
<stdio.h>
int
main()
{
int
i = 0;
int
name[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for
(i = 0; i <= 10; i++)
{
name[i] = 0;
printf("ok\n"
);
}
return
0;
}
Õâ¶Î´úÂëÒ»¿ªÊ¼ÎÒ»¹ÒÔΪÊÇС¶ù¿Æ£¬Ò»¸öºÜɵ±ÆµÄ´úÂ룬ÍêÈ«²»ÈÏΪ»áÊÇËÀÑ»·
…
ºóÀ´ÊÂʵ֤Ã÷£¬ÊÇÎÒ×Ô¼ºÉµ±ÆÁË£¬ºÃÁË£¬²»¶à˵ÁË£¬ÏÖÔÚ½ÒÏþ´ð°¸ÁË¡£
´ð°¸£º
Õâ¶Î³ÌÐò»á½øÈëËÀÑ»·£¬µ±
i
Ñ»·µ½
10
µÄʱºò£¬±íÃæÉÏ¿´ÉÏÈ¥
”name[10]= 0”
Õâ¾ä²Ù×÷ÊÇ»áÔÚÔ¤ÁÏÖ®ÍâµÄ£¬ÒòΪÊý×éÖеÄÊ®¸öÊý×ÖµÄ×îºóÒ»¸öÊÇ
name[9],
µ«¾ÍÕâ×îºóÄǾä²Ù×÷µÄʱºò£¬ÉñÆæµÄÊÂÇé·¢ÉúÁË£¬³ÌÐò·¢ÉúÁËËÀÑ»·£¬
i
ÉñÆæµÄÓÖ±»ÖóÉÁË
0.
ÆäʵµÀÀíºÜ¼òµ¥£¬ÒòΪ
name[10]
Æäʵ¾ÍÊDZäÁ¿
i,
ͨ¹ýµ÷ÊÔÎÒÃÇ¿ÉÒÔÖªµÀ£¬ÕâÁ½¸ö±äÁ¿Ö¸ÏòµØÖ·ÊÇÍêÈ«ÏàͬµÄ¡£ÔÚº¯ÊýΪ¾Ö²¿±äÁ¿ÔÚÕ»ÖÐÉêÇë¿Õ¼äµÄʱºò£¬
i
ÔÚ
name
Ç°ÃæÉêÇ룬
i
¾ÍÔÚ
name
µÄºóÃ棬ËùÒÔÒªÏÈÏò¸ßµØַдÈëÊý¾Ý£¬
i
Óë
name
Êý×éÊÇÁ¬ÐøÅÅÁеģ¬ËùÒÔ
”name[10]= 0”
Õâ¾äÆäʵ¾ÍÊÇ
”i = 0”
¡£
zz from http://blog.csdn.net/DrZinc/archive/2009/11/21/4848661.aspx
Ïà¹ØÎĵµ£º
Ò»¸ö¶¨ÒåΪvolatileµÄ±äÁ¿ÊÇ˵Õâ±äÁ¿¿ÉÄܻᱻÒâÏë²»µ½µØ¸Ä±ä£¬ÕâÑù£¬±àÒëÆ÷¾Í²»»áÈ¥¼ÙÉèÕâ¸ö±äÁ¿µÄÖµÁË¡£¾«È·µØ˵¾ÍÊÇ£¬ÓÅ»¯Æ÷ÔÚÓõ½Õâ¸ö±äÁ¿Ê±±ØÐëÿ´Î¶¼Ð¡ÐĵØÖØжÁÈ¡Õâ¸ö±äÁ¿µÄÖµ£¬¶ø²»ÊÇʹÓñ£´æÔڼĴæÆ÷ÀïµÄ±¸·Ý¡£ÏÂÃæÊÇvolatile±äÁ¿µÄ¼¸¸öÀý×Ó£º
1). ²¢ÐÐÉ豸µÄÓ²¼þ¼Ä´æÆ÷£¨È磺״̬¼Ä´æÆ ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. harderrº¯Êý
harderrº¯ÊýµÄ¹¦ÄÜÊǽ¨Á¢Ò»¸öÓ²¼þ´íÎó´¦Àí³ÌÐò£¬ÆäÓ÷¨ÊÇ£ºvoid harderr(int (*fptr)());³ÌÐòÀý×ÓÈçÏ£º
#include <stdio.h>
......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. kbhitº¯Êý
kbhitº¯ÊýÊǼì²éµ±Ç°°´Ïµļü£¬ÆäÓ÷¨Îª£ºint kbhit(void);³ÌÐòÀý×ÓÈçÏ£º
#include <conio.h>
int main(void)
{
c ......
ÒÔÏ·ÖÎö»ùÓÚ£º
Developer Platform :S60 3rd Edition, Feature Pack 2 SDK
Operating System :Symbian OS v9.3
Ò»£¬ÎªÊ²Ã´ÒªÊ¹ÓÃClient/Server¼Ü¹¹
ÔÚSymibian OSÖÐËùÓеÄÒì²½·þÎñ¶¼ÊÇServerͨ¹ýC/S¼Ü¹¹À´ÊµÏֵġ£ClientÊÇÀûÓÃServerÌṩµÄÌض¨·þÎñµÄ³ÌÐò£¬Server½ÓÊÜÀ´ÖÁClientµÄÇëÇóÏûÏ¢²¢Í¬²½»òÒì²½µ ......
VC.NETÖеÄStringÀàÊÇÀûÓÃUnicode×Ö·û¼¯±àÂëÀ´±íʾÎı¾¡£Unicode×Ö·û¼¯ÖÐÿ¸ö×Ö·û(ºº×Ö¡¢Ó¢ÎÄ×Öĸ)¶¼Õ¼2¸ö×Ö½Ú£¬ÇÒÆä×Ö·û´®ÊÇÒÔ2¸öÁ¬ÐøµÄ\0½áβµÄ¡£
ANSIµÄASCII×Ö·û¼¯ÊÇ×î³£¼ûµÄ×Ö·û¼¯£¬³£ÓÃÓÚ±íʾtxtµÄÎı¾Îļþ¡£ÔÚASCII×Ö·û¼¯ÖÐÓ¢ÎÄÕ¼Ò»¸ö×Ö½Ú£¬ºº×Ö2¸ö×Ö½Ú£¬ÇÒÆä×Ö·û´®ÊÇÒÔÒ»¸ö\0½áβµÄ¡£
ÔÚÀûÓÃVC.NET½øÐлìºÏ±à³Ìʱ ......