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

»ªÎªC/C++±ÊÊÔÌâ2

  »ªÎªC/C++±ÊÊÔÌâ2 ÊÕ²Ø
1. ij32λϵͳÏÂ, C++³ÌÐò£¬Çë¼ÆËãsizeof µÄÖµ
#include <stdio.h>
#include <malloc.h>
void Foo ( char str[100] )
{
    printf("sizeof(str)=%d \n", sizeof(str) );//´Ë´¦Ê¹ÓÃchar *strÓëchar str[100]ÊÇÒ»ÑùµÄ£¬char str[100]²»Ö¸Ã÷´óС(char str[])Ò²ÐÐ,ÒòΪ±àÒëÆ÷ÊÇ°ÑËüµ±×ö Ò»¸öÖ¸ÕëÀ´´¦ÀíµÄ
}
main()
{
    char str[] = "www.ibegroup.com";
    char *p1 = str ;
    int n = 10;
    void *p2 = malloc( 100 );
    printf("sizeof(str)=%d \n", sizeof(str) );
    printf("sizeof(p1)=%d \n", sizeof(p1) );
    printf("sizeof(n)=%d \n", sizeof(n) );
    printf("sizeof(p2)=%d \n", sizeof(p2) );
    Foo(str);//Êý×éÃûÏ൱ÓÚÒ»¸öÖ¸Õ룬ָÕëµÄ´óСΪ4£¬ËùÒÔÊä³ö4¶ø²»ÊÇ17£¬ÁíÍâsizeof ÊǼÆËãÀàÐͳ¤¶ÈµÄ£¬strlen ²ÅÊǼÆËã×Ö·û´®³¤¶ÈµÄ}
}
´ð£º(1)17  (2)4   (3) 4   (4)4   (5)4
2.  »Ø´ðÏÂÃæµÄÎÊÌâ
(1) Í·ÎļþÖÐµÄ ifndef/define/endif¸ÉʲôÓÃ? Ô¤´¦Àí
´ð£º·ÀֹͷÎļþ±»Öظ´ÒýÓÃ
(2) #include <filename.h> ºÍ #include "filename.h" ÓÐʲôÇø±ð?
´ð£º
¶ÔÓÚ#include <filename.h> £¬±àÒëÆ÷´Ó±ê×¼¿â·¾¶¿ªÊ¼ËÑË÷filename.h
¶ÔÓÚ#include "filename.h" £¬±àÒëÆ÷´ÓÓû§µÄ¹¤×÷·¾¶¿ªÊ¼ËÑË÷filename.h
(3) ÔÚC++ ³ÌÐòÖе÷Óñ» C ±àÒëÆ÷±àÒëºóµÄº¯Êý£¬ÎªÊ²Ã´Òª¼Ó extern “C”ÉùÃ÷?
´ð£ºº¯ÊýºÍ±äÁ¿±»C++±àÒëºóÔÚ·ûºÅ¿âÖеÄÃû×ÖÓëCÓïÑԵIJ»Í¬£¬±»extern "C"ÐÞÊεıäÁ¿ºÍº¯ÊýÊÇ°´ÕÕCÓïÑÔ·½Ê½±àÒëºÍÁ¬½ÓµÄ¡£ÓÉÓÚ±àÒëºóµÄÃû×Ö²»Í¬£¬C++³ÌÐò²»ÄÜÖ±½Óµ÷ÓÃC º¯Êý¡£C++ÌṩÁËÒ»¸öC Á¬½Ó½»»»Ö¸¶¨·ûºÅextern“C”À´½â¾öÕâ¸öÎÊÌâ¡£
3.  »Ø´ðÏÂÃæµÄÎÊÌâ
(1)  ÇëÎÊÔËÐÐTest º¯Êý»áÓÐʲôÑùµÄ½á¹û?
Void GetMemory(char **p, int num)
{
    *p = (char *)malloc(num);
}
void Test(void)
{
    char *str = NULL;
    GetMemory(&str, 100);
    strcpy(str, "hello");
    printf(str);
}
´ð£ºÊä³ö“hello”


Ïà¹ØÎĵµ£º

¼òÊöCºÍC++³ÌÐòԱѧϰÀú³Ì

¹þ¹þ£¡ÓÐÐÒÔÚijÍøÕ¾·¢ÏÖÕâƪÎÄÕ£¬¶Á°Õ£¬¾õµÃÂùÓеÀÀí£¬·¢À´´ó¼ÒÒ»Æð¹²ÃãÖ®   
×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½£¬ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
¡¡¡¡Ò»¼ÒÖ®ÑÔ£¬»¶Ó­ÅÄש¹þ¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû ......

C++ÓëC»ìºÏ±à³Ì(ת)

(ת)C++ÖÐextern “C”º¬ÒåÉî²ã̽Ë÷
 
 
1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏó&rdquo ......

DSP CÓÅ»¯2

3.4Àí½â±àÒëÆ÷µÄ·´À¡ÐÅÏ¢
    ÔÚ±àÒëC´úÂëʱ£¬±àÒëÆ÷ÔÚ²úÉúµÄ.asmÎļþÀïÏò³ÌÐòÔ±·´À¡ÁËÐí¶àÐÅÏ¢£¬Àí½âÕâЩÐÅÏ¢£¬°´ËüµÄÌáʾÐÞ¸ÄC´úÂ룬¶Ô¾¡¿ìÓÅ»¯´úÂëºÜÓкô¦¡£Ö»ÒªÓÃ-kÁî±àÒëÆ÷±£Áô.asmÎļþ£¬¾Í¿É¶Áµ½ÕâЩÐÅÏ¢¡£
    ¶ÔÓÚCÓÅ»¯£¬Öصã¾ÍÊÇÑ­»·£¬¶ÔÓÚ·´À¡ÐÅÏ¢£¬ÎÒÃÇÖ÷Òª¿¼²ì±àÒëÆ÷¶ÔÁ÷Ë®Ïß ......

C/C++ ±Ê¼Ç£¨ÁãËéµã£©

1£©a = a + 5; Óë a += 5£»µÄÇø±ð¡£
    ¶þÕßÔÚ¹ãÒåÉÏÊǵȼۡ£D.Ritchie ÔÚCÓïÑÔÖÐÒýÈ븴ºÏÔËËã·ûµÄÖ÷ҪĿµÄÊÇΪÁËÌá¸ß±àÒëµÄЧÂÊÒÔ²úÉú¸ßÖÊÁ¿µÄÖ´ÐдúÂë¡£ÒòΪÕâЩÔËËã·ûµÄ¹¦ÄÜ»ù±¾É϶¼ÄÜÓÃÒ»¶þÌõ»úÆ÷Ö¸ÁîÀ´Íê³É¡£
2£©ÔÚC++ÖÐlong Óë int µÄÇø±ð
NameDescriptionSize*Range*
char
Character or s ......

¼òÊöCºÍC++³ÌÐòԱѧϰÀú³Ì

    ×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½,ÈçºÎѧϰCºÍC++²Å²»Ã£È»,²Å²»ÊÇÂÒѧ¡£ÏëÁËÒ»ÏÂ,ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
    Ò»¼ÒÖ®ÑÔ,»¶Ó­ÅÄש¹þ¡£
    1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC
    ´ó¶àÊýʱºò,ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ,²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò,¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ