CÖÐÀ¨ºÅÓÅÏȼ¶µÄ˼¿¼
ÎÊÌâÔ´ÓÚÂÛ̳µÄÒ»µÀÌâÄ¿£º
http://topic.csdn.net/u/20100216/21/ec98464e-a47e-4263-bb1c-a001e130ba87.html
ÏÂÃæÊÇÎÊÌ⣺
Éèint arr[]={6,7,8,9,10};
int *ptr=arr;
*(ptr++)+=123;
printf(£¢%d,%d£¢,*ptr,*(++ptr));
´ð°¸ÎªÊ²Ã´ÊÇ£º8£¬8
ÎÊÌâµÄ½¹µãÒ²ÂäÔÚprintfÖ´ÐеÄÎÊÌâÉÏ£¬µ½µ×ÏÈÖ´ÐÐË£¬ºóÖ´ÐÐË£¬ »¹Óв¿·ÖÓвÅÇàÄ꽫¸ÃÎÊÌâÖÐÓ¹»¯£¬¾õµÃ¸ú±àÒëÆ÷Óйء£
Ö´ÐеÄ˳ÐòÕæµÄ¸ú±àÒëÆ÷ÓйØÂð? ºóÃæÔÙÌÖÂÛÕâ¸öÎÊÌâ¡£
printfÖ´ÐеÄÎÊÌ⣬ ÍêÈ«¿ÉÒÔ¹é½áº¯ÊýÖ´ÐÐ˳ÐòµÄͨÓÃÎÊÌ⣬ ËùÒÔ£¬ÓÃÀý×ÓÀ´½«¸ÃÎÊÌâ³éÏ󻯣º
#include <stdio.h>
int left()
{
printf("left \n");
return 0;
}
int right()
{
printf("right \n");
return 0;
}
int myFunction(int a, int b)
{
return 0;
}
int main()
{
myFunction(left(),right());
}
Ö´ÐеĽá¹ûÊÇ£º
right
left
´ÓÖпÉÒÔ¿´³öÀ´£¬ À¨ºÅÖÐ(Àí½âΪº¯Êý¼´¿É)£¬ Ö´ÐеÄ˳ÐòÊÇÏÈ´ÓÓұߣ¬ÔÙ´Ó×ó±ß¡£
ÏÖÔÚ£¬ÔÙ¿¼ÂDZàÒëÆ÷µÄÓ°Ï죬 ÎÒÃÇ˵µÄ±àÒëÆ÷²»ÊÇÄã×Ô¼Ò¿ª·¢µÄ±àÒëÆ÷£¬ Õâ¸öÊÀ½çÉÏ×ÜÓÐЩBTµÄ»ú¹¹£¬ ¿ÉÄÜÒ²»á¿ª·¢Ò»¸ö±àÒëÆ÷£¬¿ÉÄÜÒ²¸ãЩ·Ç³£BTµÄ¹¦ÄÜ(ÀàËÆÓÚÔÛÒƶ¯Ï²»¶½«±ðÈ˺úõÄWIFI¸øÑ˸îÁË), ÎÒÃDz»ÌÖÂÛBTµÄ¸ö°¸¡£
ANSI CµÄ±ê×¼ÖУ¬Ò»Ìõ²»³ÉÎĵĹ涨ÊÇ£¬ Ä¿±ê²ÎÊýÍùÍù×÷ΪµÚÒ»¸ö²ÎÊý£¬ ÀàËÆÓÚstrcpy(dst, src). Õâ¸ö¹æ¶¨£¬Ö÷Á÷µÄ±àÒëÆ÷¶¼ÈÏͬÕâÑùÒ»Ìõ¹æÔò£¬ ÔÚ²Ù×ÝÄ¿±ê֮ǰ£¬ ±Ø¶¨ÏÈÒª½«Ô´ºÃºÃ´¦ÀíÒ»°Ñ£¬ ËùÒÔ£¬ º¯ÊýÖУ¬Ò²¾ÍÊÇÀ¨ºÅÖУ¬È·¶¨µÄÓÅÏȼ¶£¬ÊÇ´Ó×îÓұߣ¬Ò²¾ÍÊÇ´ÓsrcÔ´¿ªÊ¼´¦Àí£¬´¦ÀíÍêºó£¬ÔÙ½øÒ»²½´¦ÀídstµÄ¡£
ÕâÑùµÄÉè¼Æ£¬¼È·ûºÏANSI CµÄÔ¼¶¨£¬ Ò²·ûºÏ´¦Àí³£Ê¶¡£
Èç¹ûÕæµÄÓбàÒëÆ÷²»°´ÕÕÕâÌõ·×ߵģ¬ ±ÀÀ£µÄ²»ÊdzÌÐò£¬¶øÊÇCoder.
Ïà¹ØÎĵµ£º
ʱ³£ÔÚcppµÄ´úÂëÖ®Öп´µ½ÕâÑùµÄ´úÂë:
#ifdef __cplusplus
extern "C" {
#endif
//Ò»¶Î´úÂë
#ifdef __cplusplus
}
#endif
ÕâÑùµÄ´úÂëµ½µ×ÊÇʲôÒâ˼ÄØ£¿Ê×ÏÈ£¬__cplusplusÊÇcppÖеÄ×Ô¶¨Òåºê£¬ÄÇô¶¨ÒåÁËÕâ¸öºêµÄ»°±íʾÕâÊÇÒ»¶ÎcppµÄ´úÂ룬Ҳ¾ÍÊÇ˵£¬ÉÏÃæµÄ´úÂëµÄº ......
±¾ÎĽéÉÜÔÚGNU/Linux»·¾³ÏÂÒ»¸öC³ÌÐòÓÉÔ´´úÂëµ½³ÌÐò£¬µ½¼ÓÔØÔËÐУ¬×îºóÖÕÖ¹µÄ¹ý³Ì¡£Í¬Ê±ÒԴ˹ý³ÌΪÔØÌ壬½éÉÜGNU/Linuxƽ̨ÏÂÈí¼þ¿ª·¢¹¤¾ßµÄʹÓá£
±¾ÎÄÒÔÎÒÃÇ×î³£¼ûµÄhello, world!ΪÀý£º
#include <stdio.h>
main ()
{
printf(“hello, world!\n” ......
http://man.lupaworld.com/content/develop/c&c++/c/c.htm
1. Èç¹û²ÎÊýÊÇÖ¸Õ룬ÇÒ½ö×÷ÊäÈëÓã¬ÔòÓ¦ÔÚÀàÐÍÇ°¼Óconst£¬ÒÔ·ÀÖ¹¸ÃÖ¸ÕëÔÚº¯ÊýÌåÄÚ±»ÒâÍâÐÞ¸Ä
2. ÔÚº¯ÊýÌåµÄ“Èë¿Ú´¦”£¬¶Ô²ÎÊýµÄÓÐЧÐÔ½øÐмì²é
ÔÚº¯ÊýÌåµÄ“³ö¿Ú´¦”£¬¶ÔreturnÓï¾äµÄÕýÈ·ÐÔºÍЧÂʽøÐмì ......
Êý×鸳ֵÎÒ×ܽáһϰÉÒ²¾ÍÈýÖÖ£¬ÄÇcharµÄÀ´¾ÙÀý£º
¶¨ÒåµÄʱºòÖ±½Ó¸³Öµ.
1£ºchar a[20] = "Hello World!";
2: char a[20];
strcpy(a, "Hello World!");
3:char a[20] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'};
³£¼û´íÎó¸³Öµ·½Ê½:
1:char a[20];
a = "Hello World ......