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

¡¶CÓïÑÔÉî¶ÈÆÊÎö¡·Ñ§Ï°±Ê¼ÇÈý

1.10.3£¬voidÖ¸Õë
¡¾¹æÔò 1-35¡¿Ç§ÍòСÐÄÓÖСÐÄʹÓÃvoidÖ¸ÕëÀàÐÍ¡£
°´ÕÕ ANSI(American National Standards Institute)±ê×¼£¬²»ÄÜ¶Ô voidÖ¸Õë½øÐÐËã·¨²Ù×÷£¬¼´ÏÂÁвÙ×÷¶¼ÊDz»ºÏ·¨µÄ£º
void * pvoid;
pvoid++; //ANSI£º´íÎó
pvoid += 1; //ANSI£º´íÎó
ANSI ±ê×¼Ö®ËùÒÔÕâÑùÈ϶¨£¬ÊÇÒòΪËü¼á³Ö£º½øÐÐËã·¨²Ù×÷µÄÖ¸Õë±ØÐëÊÇÈ·¶¨ÖªµÀÆäÖ¸ÏòÊý¾ÝÀàÐÍ´óСµÄ¡£Ò²¾ÍÊÇ˵±ØÐëÖªµÀÄÚ´æÄ¿µÄµØÖ·µÄÈ·ÇÐÖµ¡£
ÀýÈ磺
int *pint;
pint++; //ANSI£ºÕýÈ·
µ«ÊÇ´óÃû¶¦¶¦µÄ GNU(GNU's Not UnixµÄµÝ¹éËõд)Ôò²»ÕâôÈ϶¨£¬ËüÖ¸¶¨ void *µÄËã·¨²Ù×÷Óë char *Ò»Ö¡£Òò´ËÏÂÁÐÓï¾äÔÚGNU±àÒëÆ÷ÖнÔÕýÈ·£º
pvoid++; //GNU£ºÕýÈ·
pvoid += 1; //GNU£ºÕýÈ·
ÔÚʵ¼ÊµÄ³ÌÐòÉè¼ÆÖУ¬Îª·ûºÏ ANSI±ê×¼£¬²¢Ìá¸ß³ÌÐòµÄ¿ÉÒÆÖ²ÐÔ£¬ÎÒÃÇ¿ÉÒÔÕâÑù±àд
ʵÏÖͬÑù¹¦ÄܵĴúÂ룺
void * pvoid;
(char *)pvoid++; //ANSI£ºÕýÈ·£»GNU£ºÕýÈ·
(char *)pvoid += 1; //ANSI£º´íÎó£»GNU£ºÕýÈ·
GNUºÍ ANSI »¹ÓÐһЩÇø±ð£¬×ÜÌå¶øÑÔ£¬GNU ½Ï ANSI ¸ü“¿ª·Å”£¬ÌṩÁ˶Ըü¶àÓï·¨µÄÖ§³Ö¡£µ«ÊÇÎÒÃÇÔÚÕæʵÉè¼Æʱ£¬»¹ÊÇÓ¦¸Ã¾¡¿ÉÄܵطûºÏ ANSI ±ê×¼¡£
¡¾¹æÔò 1-36¡¿Èç¹ûº¯ÊýµÄ²ÎÊý¿ÉÒÔÊÇÈÎÒâÀàÐÍÖ¸Õ룬ÄÇôӦÉùÃ÷Æä²ÎÊýΪvoid *¡£
µäÐ͵ÄÈçÄÚ´æ²Ù×÷º¯Êý memcpy ºÍ memset µÄº¯ÊýÔ­ÐÍ·Ö±ðΪ£º
void * memcpy(void *dest, const void *src, size_t len);
void * memset ( void * buffer, int c, size_t num );
ÕâÑù£¬ÈκÎÀàÐ͵ÄÖ¸Õ붼¿ÉÒÔ´«Èë memcpyºÍ memset ÖУ¬ÕâÒ²ÕæʵµØÌåÏÖÁËÄÚ´æ²Ù×÷º¯ÊýµÄÒâÒ壬 ÒòΪËü²Ù×÷µÄ¶ÔÏó½ö½öÊÇһƬÄڴ棬 ¶ø²»ÂÛÕâƬÄÚ´æÊÇʲôÀàÐÍ¡£ Èç¹ûmemcpyºÍmemsetµÄ²ÎÊýÀàÐͲ»ÊÇvoid *£¬ ¶øÊÇchar *£¬ ÄDzŽÐÕæµÄÆæ¹ÖÁË£¡ ÕâÑùµÄmemcpyºÍmemsetÃ÷ÏÔ²»ÊÇÒ»¸ö“´¿´âµÄ£¬ÍÑÀëµÍ¼¶È¤Î¶µÄ”º¯Êý£¡
ÏÂÃæµÄ´úÂëÖ´ÐÐÕýÈ·£º
Àý×Ó£ºmemset ½ÓÊÜÈÎÒâÀàÐÍÖ¸Õë
int IntArray_a[100];
memset (IntArray_a, 0, 100*sizeof(int) ); //½« IntArray_aÇå0
Àý×Ó£ºmemcpy ½ÓÊÜÈÎÒâÀàÐÍÖ¸Õë
int destIntArray_a[100], srcintarray_a[100];
//½« srcintarray_a¿½±´¸ø destIntArray_a
memcpy (destIntArray_a, srcintarray_a, 100*sizeof(int) );
ÓÐȤµÄÊÇ£¬memcpy ºÍ memsetº¯Êý·µ»ØµÄÒ²ÊÇ void *ÀàÐÍ£¬±ê×¼¿âº¯ÊýµÄ±àдÕ߶¼²»ÊÇÒ»°ãÈË¡£
1.10.4£¬void²»ÄÜ´ú±íÒ»¸öÕæʵµÄ±äÁ¿
¡¾¹æÔò 1-37¡¿void²»ÄÜ´ú±íÒ»¸öÕæʵµÄ±äÁ¿¡£
ÒòΪ¶¨Òå±äÁ¿Ê±±ØÐë·ÖÅäÄÚ´æ¿Õ¼ä£¬¶¨Òå vo


Ïà¹ØÎĵµ£º

ÉîÈëÀí½âextern "C"

Ò»¡¢´ÓCÓëC++±àÒëÁ¬½Ó·½Ê½ÉîÈëÀí½âextern "C"
<1>.CºÍC++¶Ôº¯ÊýµÄ´¦Àí·½Ê½ÊDz»Í¬µÄ.±»extern "C"ÐÞÊεıäÁ¿ºÍº¯ÊýÊÇ°´ÕÕCÓïÑÔ·½Ê½±àÒëºÍÁ¬½ÓµÄ.extern "C"ÓÃÓÚʵÏÖC++ÓëC¼°ÆäËüÓïÑԵĻìºÏ±à³Ì¡£
<2>.δ¼Óextern “C”ÉùÃ÷ʱµÄ±àÒ뷽ʽ
Ê×ÏÈ¿´¿´C++ÖжÔÀàËÆCµÄº¯ÊýÊÇÔõÑù±àÒëµÄ¡£
×÷ΪһÖÖÃæÏò ......

ǶÈëʽ¿ª·¢£­CÓïÑÔÃæÊÔÌâ(¶þ)

11¡¢ÏÂÃæµÄ´úÂëÊä³öÊÇʲô£¬ÎªÊ²Ã´£¿
Void foo(void)
{
unsigned int a = 6;
int b = -20;
(a+b > 6) £¿puts("> 6") : puts("<= 6");
}
²»¹ÜÈçºÎ£¬ÕâÎÞ·ûºÅÕûÐÍÎÊÌâµÄ´ð°¸ÊÇÊä³öÊÇ“>6”¡£Ô­ÒòÊǵ±±í´ïʽÖдæÔÚÓзûºÅÀàÐͺÍÎÞ·ûºÅÀàÐÍʱËùÓеIJÙ×÷Êý¶¼×Ô¶¯×ª»»ÎªÎÞ·ûºÅÀàÐÍ¡£Òò´Ë-20±ä³ÉÁËÒ»¸ ......

UNIXÏÂC±à³ÌÎÊÌâ

ÉÏѧÆÚ¼ä»ù±¾É϶¼ÔÚwindowsϱà³Ì£¬¾ÍÊÇѧÁËÒ»µãLINUX£¬Ò²ÊÇһЩ»ù±¾²Ù×÷£¬ÔÚLINUXϱà³Ì¼¸ºõûÓйý£¬ÉÏ°àºó¶¼ÊÇÔÚUNIXϵĿª·¢£¬Í»È»Ö®¼äÓеã¸Ð¾õ×Ô¼ºÎÞ´¦ÏÂÊÖ£¬¸Ð¾õ²»»áÁË£¬×鳤ÈÃÎÒ±àÒ»¸ö³ÌÐò£¬ÎÒÏëÁË°ëÌìÔÚÍøÉϲéÁË°ëÌ죬Óеã˼·ÁË£¬ÔÚ±àÒëʱȷʵ´íÎóÁ¬Á¬£¬¸Ð¾õ¶¼ºÜÓÐѹÁ¦£¬µ«ÎÒ»áÂýÂýÏ°¹ßµÄ£¬ÎÒÏàÐÅ×Ô¼º¡£
ÎÊÌ⣺
1 ......

C/C++ÖÐö¾ÙÀàÐÍ(enum)

Èç¹ûÒ»¸ö±äÁ¿ÄãÐèÒª¼¸ÖÖ¿ÉÄÜ´æÔÚµÄÖµ£¬ÄÇô¾Í¿ÉÒÔ±»¶¨Òå³ÉΪö¾ÙÀàÐÍ¡£Ö®ËùÒÔ½Ðö¾Ù¾ÍÊÇ˵½«±äÁ¿»òÕ߽жÔÏó¿ÉÄÜ´æÔÚµÄÇé¿öÒ²¿ÉÒÔ˵ÊÇ¿ÉÄܵÄÖµÒ»Ò»Àý¾Ù³öÀ´¡£
¡¡¡¡¾Ù¸öÀý×ÓÀ´ËµÃ÷Ò»°É£¬ÎªÁËÈôó¼Ò¸üÃ÷°×Ò»µã£¬±ÈÈçÒ»¸öǦ±ÊºÐÖÐÓÐÒ»Ö§±Ê£¬µ«ÔÚûÓдò¿ªÖ®Ç°Äã²¢²»ÖªµÀËüÊÇʲô±Ê£¬¿ÉÄÜÊÇǦ±ÊÒ²¿ÉÄÜÊǸֱʣ¬ÕâÀïÓÐÁ½ÖÖ¿ÉÄÜ£¬Ä ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ