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

CÓëC++·ç¸ñ×Ö·û´®

C·ç¸ñ×Ö·û´®£º¶Ô×Ö·û´®½øÐвÙ×÷µÄ C º¯Êý¶¨ÒåÔÚÍ·Îļþ<cstring>ÖУ»
     1. ×Ö·û´®¶¨Ò壺char* result£»
     2. ×Ö·û´®µÄ×îºóÒ»¸ö×Ö·ûÊÇnull×Ö·û£¨'\0'£©£¬¿ÉÒÔͨ¹ýÕâ¸ö×Ö·ûÈ·¶¨×Ö·û´®µÄ½áβ¡£
     3. strlen()·µ»ØµÄÊÇ×Ö·û´®µÄ´óС£»Òò´Ë£¬·ÖÅä¿Õ¼äµÄʱºò£¬ÐèÒª±È×Ö·û´®µÄʵ¼Ê¿Õ¼ä´ó1.
     e.g. char* copyString(const char* inString)
          {
             char *result = new char[strlen(inString)];//BUG£¡ off by one
             strcpy(result, inString);
             return result;
           }
      explain£º strlen£¨£©·µ»ØµÄÊÇ×Ö·û´®µÄ´óС£¬±ÈÈç"ab"£¬·µ»ØµÄÊÇ2¡£¶øÔÚnew½øÐзÖÅäµÄʱºò£¬ÐèҪΪ'\0'·ÖÅäÒ»¸ö¿Õ¼ä¡£·ÖÅäÓï¾äҪд×÷£¬char *result = new char[strlen(inString) + 1];
    4. strcpy(a,b)£º½«×Ö·û´®bµÄÄÚÈݸ³Öµ¸ø×Ö·û´®a£»aµÄ´óС¿ÉÒÔ´óÓÚb£¬½«b·ÅÔÚaµÄ¿ªÊ¼µÄλÖã»
      strcat(a£¬b)£º½«×Ö·û´®bÆ´½Óµ½×Ö·û´®aµÄÏÖÓÐ×Ö·ûºóÃ棻
C++·ç¸ñ×Ö·û´®£ºÊ¹ÓÃC++·ç¸ñ×Ö·û´®µÄʱºò£¬Òª½«Ëüµ±×öÊÇÒ»¸öÆÕͨµÄÀàÐÍ£¬Èçint£¬ÕâÑù·´¶ø»á±ÜÃ⽫string×÷Ϊһ¸öÀàÀ´Àí½âËù´øÀ´µÄºÜ¶àÎÊÌâ¡£
     1. Ö§³Ö<cstring>ÖÐÐí¶àº¯ÊýÍê³ÉµÄͬÑù²Ù×÷¡£
     2. ×Ö·û´®¶¨Ò壺string myString = “hello”£»
     3. ²Ù×÷·û = £º¸´ÖÆ×Ö·û´®£»±ÈÈ磬string newone = original£»»á½«ºóÕ߸´ÖƸøÇ°Õߣ¬²»»á³öÏÖÁ½¸ö±äÁ¿Í¬ÑùÖ¸ÏòÒ»¸öÄÚ´æµÄÇé¿ö¡£
     4. ¿ÉÒÔÏñintÒ»ÑùʹÓà == Ö®ÀàµÄ²Ù×÷·û
     5. ¿ÉÒԸıä×Ö·û´®ÖеÄijһ¸ö×Ö·û¡£ Èç string myString = "hello"; mystring[0] = 'l'; ÕâÖвÙ×÷ÊÇÔÊÐíµÄ¡£
×Ö·û´®Ö±½ÓÁ¿£º×Ö·û´®Ã»ÓбäÁ¿Ãû×Ö£¬×ÔÉí±íʾ×ÔÉí¡£
    1. string literal£º×Ö·û´®Ö±½ÓÁ¿£º


Ïà¹ØÎĵµ£º

C¡¢C++ºÍC#µÄ²»Í¬Ö®´¦

CÊÇÃæÏò¹ý³ÌµÄ³ÌÐòÉè¼Æ£¬³ÌÐò=Êý¾Ý½á¹¹+Ëã·¨ [×îԭʼ£¬µ«±à¸ö³Ìȷʵ²»Ò×]
C++ÊÇÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼Æ£¬³ÌÐò=¶à¸öÀà+ÏûÏ¢(Àà=Êý¾Ý½á+Ëã·¨)[±È½ÏÈÝÒ×ÉÏÊÖ]
C# ÊÇ´¿ÃæÏò¶ÔÏóµÄÓïÑÔ[¸ü¼Ó±È½ÏÈÝÒ×ÉÏÊÖ]
VC/VC++/VC# Ö»ÊÇÓÃÀ´¿ª·¢C/C++/C#Ó¦ÓóÌÐòµÄÈí¼þÖеÄÒ»ÖÖ¡£
......

¾­µäc/c++Ëã·¨

¶þ·Ö²éÕҵĴúÂë.
int bfind(int* a,int len,int val)
{
    int m = len/2;
    int l = 0;
    int r = len;
    while(l!=m && r!= m)
    {
        if(a[m] > val)
  & ......

C/C++±ÊÊÔÃæÊÔÌâÄ¿

1£®ÒÑÖªstrcpy º¯ÊýµÄÔ­ÐÍÊÇ£º
char *strcpy(char *strDest, const char *strSrc);
ÆäÖÐstrDest ÊÇÄ¿µÄ×Ö·û´®£¬strSrc ÊÇÔ´×Ö·û´®¡£²»µ÷ÓÃC++/C µÄ×Ö·û´®¿âº¯Êý£¬Çë±àдº¯Êý strcpy
´ð°¸£º
char *strcpy(char *strDest, const char *strSrc)
{
if ( strDest == NULL || strSrc == NULL)
return NULL ;
if ( strDest ......

¿É±äÄ¿±êC±àÒëÆ÷ µÚ4Õ ÀàÐÍ

C³ÌÐòÖоßÓзḻµÄÊý¾ÝÀàÐÍ£¬°üÀ¨ÉùÃ÷ÖÐÏÔʽ¶¨ÒåµÄÀàÐͺÍÓÃ×ö±í´ïʽÖмäÀàÐ͵ĵ¼³öÀàÐÍ¡£ÀýÈ磬ÏÂÃæµÄ¸³ÖµÓï¾ä°üº¬3 ÖÖ²»Í¬ÀàÐÍ:
    int *p, x;
    *p = x;
xÊÇÒ»¸ö´æ·ÅÕûÊýµÄµ¥ÔªµÄµØÖ·£¬Òò´ËxµÄµØÖ·µÄÀàÐÍÊÇ£ºÖ¸ÏòÒ»¸öÕûÊýµÄÖ¸Õë¡£xµÄÖµµÄÀàÐÍÊÇÕûÐÍ¡£Í¬Ñù, pµÄ×óÖµµÄÀàÐÍÊÇÖ¸ÏòÒ»¸öÕ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ