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

¹ØÓÚC¡¢C++ÖеÄconstºÍÖ¸Õë

żȻµÄÒòËØ£¬¶ÔconstÀ´Á˵ãÐËȤ£¬×öÁËÒ»ÏÂʵÑ飺
1. Óï·¨£ºconst¡¢Ö¸Õë
       ÔÚgccÖУ¬ ¶ÔÓÚCÓïÑÔ£¬ÏÂÃæµÄÓï¾äÊǺϷ¨µÄ£º
const int a=0;
int *p=&a;
      ¶øC++ÖУ¬ÐèÒªÊÖ¹¤Ç¿ÖÆת»»²ÅÄܱàÒëͨ¹ý£º
           const int a=0£»
           int *p=£¨int *£©&a£»
2.  ¼ÈÈ»Äܹ»½«const±äÁ¿µÄµØÖ·¸³¸øÖ¸Ïò·Çconst±äÁ¿µÄÖ¸Õ룬ÄÇôÄÜ·ñ¸Ä±äͨ¹ýÖ¸Õë¸Ä±äconst±äÁ¿µÄÖµÄØ£¿
    1)ÔÚgccÖУ¬±àÒëÖ´ÐÐÒÔÏ´úÂ룺
const    int c=2;
      int *p=&c;
      *p=1;
printf("c is :%d\n",c);
±àÒëʱ»áÓо¯¸æ£º¾¯¸æ£º³õʼ»¯¶ªÆúÁËÖ¸ÕëÄ¿±êÀàÐ͵ÄÏÞ¶¨
½á¹ûΪ£º
c is 1
 
˵Ã÷ËäÈ»Óо¯¸æ£¬µ«ÊÇ˳Àû±àÒëͨ¹ý£¬²¢Çҳɹ¦¸Ä±äÁ˳£Á¿cµÄÖµ£¨´Ó2±äΪ1£©¡£
     2.½ÓÏÂÀ´¿´ÏÂÃæÒ»¶Î´úÂ룺
#include <stdio.h>
#include <unistd.h>
int main(void)
{
      const   int c=2;
      int a=0;
     
      const int *p;
      p=&a;
     
      int *p2=&a;
      p2[1]=-1;
 
      printf("p2[1] is :%d\n",p2[1]);
      printf("a is :%d\n",a);
      printf("c is :%d\n",c);
      printf("c address is:%d\n",&c);
      printf("p2[1] address is:%d\n",p2+1);
      printf("*(&c) is :%d\n",*(&c));
}
Õâ¶Î´úÂ룬³ÌÐò»áÓÐÔõÑùµÄÊä³öÄØ£¿
1.±£´æΪºó׺Ϊ.cµÄÎļþ£¬ÓÃgcc±àÒ룬ִÐнá¹ûÈçÏ£º
p2[1] is :-1
a is :0
c is :-1
c address is:-1076230280
p2[1] address is:-1076230280
*(&c) is :-1
˵Ã÷p2+1µÄµØÖ·ºÍcµÄµØÖ·Ò»Ñù£¬³ÌÐò³É¹¦µÄ¼ä½Ó¸Ä±äÁËcµÄÖµ£¨p2Ô½½ç·ÃÎ


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

ÓÃCдµÄ3DÃÔ¹¬

          Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
       ´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸еģ¬»î»î»î£¡
         &n ......

´Ó±àд¿çƽ̨³ÌÐò̸CºÍC++

    ¹¤×÷ºóÎÒ×ÐϸÔĶÁÁ˹«Ë¾µÄ3DÒýÇæµÄÔ´´úÂ룬ÕâÊÇ¿îά»¤ÁËÊ®¼¸ÄêµÄÒýÇ棬Ö÷ÒªÔËÐÐÔÚXBox, PS3ºÍPCƽ̨ÉÏ¡£ºËÐIJ¿·ÖÓÃCÓïÑÔд£¬ÆäËû²¿·Ö×é¼þÓÃC++±àд¡£ÎÒÒÔÇ°ºÜÉÙÓÃCÓïÑÔ±à³Ì(°Ý´óѧ½ÌÓýËù´Í)£¬µ«¶ÁÁËÌ«¶àÕâ¿îÒýÇæµÄ´úÂëÉîÉîµÄÖÐÁËCÓïÑԵĶ¾¡£C¸øÎҵĸоõ¾ÍÊǼòµ¥Ã÷ÁË£¬Òª½â¾öÎÊÌâ¾ÍÊÇÖ±½ÓÈ¥½â¾öËü£¬¾ø²»¹ ......

×Ö·û´®×ªÊý×Ö£¬Êý×Öת×Ö·û´®Cº¯Êý

atof(½«×Ö·û´®×ª»»³É¸¡µãÐÍÊý)
atoi(½«×Ö·û´®×ª»»³ÉÕûÐÍÊý)
atol(½«×Ö·û´®×ª»»³É³¤ÕûÐÍÊý)
strtod(½«×Ö·û´®×ª»»³É¸¡µãÊý)
strtol(½«×Ö·û´®×ª»»³É³¤ÕûÐÍÊý)
strtoul(½«×Ö·û´®×ª»»³ÉÎÞ·ûºÅ³¤ÕûÐÍÊý)
toascii(½«ÕûÐÍÊýת»»³ÉºÏ·¨µÄASCII Âë×Ö·û)
toupper(½«Ð¡Ð´×Öĸת»»³É´óд×Öĸ)
tolower(½«´óд×Öĸת»»³ÉСд×Öĸ) ......

CµÄ¶¯Ì¬ÄÚ´æ¹ÜÀí mallac()ºÍfree()

      ¹ØÓÚcµÄ¶¯Ì¬ÄÚ´æ¹ÜÀíÒ»Ö±ÊǸö¾­¾Ã²»Ë¥µÄ»°Ìâ,ÃæÊÔÒ²ÊÇ»ù±¾É϶¼»á¿¼µÄ,±¾À´¸Ð¾õÒѾ­Ã÷°×ÁË,µ«ÊǽñÌìʹÓõÄʱºòÒ»²»Ð¡Ðĵ¼Ö³ÌÐò±ÀÀ£ÁË,Òò´ËÉîÈëµÄÈ¥²éÁËÏÂ×ÊÁÏ,ÊÕ»ñ²»ÉÙ...Ìù³öÀ´Óë´ó¼Ò·ÖÏí...
     ÏÈÌù¸ö´íÎó´úÂë:
     int * ptr = (int *)mal ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ