CÖ¸ÕëÒÜÏë
Ö¸Õë,ÖÚËùÖÜÖª,ʱΪһÄÚ´æµØÖ·.Å׿ªOS¼¶±ð»ò¸üµÍµÄÓ²¼þ¼¶±ð²»Ëµ,½ö¶ÔÓ¦ÓÃÄÚµÄʹÓýøÐÐССµÄÒܲâÌÖÂÛ.
Ê×ÏÈ,ÔÚÓ¦ÓÃÄÚ,ÓÃmallocÉêÇëµ½µÄÒ»¿éµØÖ·Ó¦¸ÃÊÇÁ¬ÐøµÄ(²Â²â,Âß¼ÉÏÁ¬Ðø,ʵ¼ÊÉÏÎïÀíÈçºÎ·Ö²¼²»Óè¹Ø×¢).
Æä´Î,Êý¾Ý´æÔÚÔÚÄÚ´æÖж¼ÊÇÒÔ2½øÖÆÐÎʽ´æ·Å.²»´æÔÚÊý¾ÝÀàÐÍ,Òò´Ë,¶ÔÄÚ´æÊý¾ÝµÄ²Ù×÷,Ö»Òª×ñѽø³öÀàÐÍÒ»Ö¼´¿É.
´Ë´¦µÄ½ø,ÊÇÖ¸½«Êý¾Ý´æ·Åµ½ÄÚ´æÖÐ,Èç´æ½øÒ»¸öintÐ͵ÄÊý¾Ý,¶ÁÈ¡µÄʱºò°´int¶ÁÈ¡¼´¿É,´æ´¢Ò»¸öchar*µÄÊý¾Ý,°´char*¶ÁÈ¡¼´¿É.
#define mAlloc(p,size)\
{\
errno=0;\
if((p=(char*)malloc(sizeof(char)*size)))==null){\
printf("malloc error[%d]\n",errno);\
exit(-1);\
}\
memset(p,0,sizeof(char)*size);\
}\
#define setInt(p,v) (*(int*)(p)=v)
#define setStr(p,v,size) strcpy(p,v)
int main()
{
char *p;
mAlloc(p,10);
setInt(p,100);
printf("int:%d\n",*(int*)p);
setStr(p+sizeof(int),"abc");
printf("str:%s\n",p+sizeof(int));
return 1;
}
Ïà¹ØÎĵµ£º
C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”,µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ.×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ,C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌصã(±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏó”),Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý.µ«ÊÇ,C++±Ï¾¹ÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄ³ÌÐ ......
1¡¢Java JDKµÄ°²×°
EclipseÊÇÒ»¿î¿çƽ̨µÄ¹¤¾ß£¬Ö»ÐèÒª»ù±¾µÄjavaÐéÄâ»ú¾Í¿ÉÒÔÔËÐС£
°²×°Java
SDKºÜ¼òµ¥¡£µ½http://java.sun.comÉÏÕÒµ½ÊʺÏÄãµÄ²Ù×÷ϵͳµÄJava
JDK°²×°³ÌÐò£¬ÏÂÔØÖ®²¢ÔËÐУ¬Java SDK¾Í»á°²×°µ½ÄãµÄϵͳÖС£
×¢Ò⣬¸ü¸ß°æ±¾µÄEclipseÐèÒª¸ü¸ß°æ±¾µÄJava JDK¡£
2¡¢Eclipse¼°CDTµÄ°²×°
µ½EclipseµÄ¹Ù·½ ......
1. ½çÃæ¹æ·¶
1.1. ×ÜÌåÔÔò
l ÒÔÓû§ÎªÖÐÐÄ¡£Éè¼ÆÓÉÓû§¿ØÖƵĽçÃ棬¶ø²»ÊǽçÃæ¿ØÖÆÓû§¡£
l Çå³þÒ»ÖµÄÉè¼Æ¡£ËùÓнçÃæµÄ·ç¸ñ±£³ÖÒ»Ö£¬ËùÓоßÓÐÏàͬº¬ÒåµÄÊõÓï±£³ÖÒ»Ö£¬ÇÒÒ×ÓÚÀí½â
l ÓµÓÐÁ¼ºÃµÄÖ±¾õÌØÕ÷¡£ÒÔÓû§ËùÊìϤµÄÏÖʵÊÀ½çÊÂÎñµÄ³éÏóÀ´¸øÓû§°µÊ¾ºÍÒþÓ÷£¬À´°ïÖúÓû§ÄÜѸËÙѧ»áÈí¼þµÄʹÓá£
l ½Ï¿ìµÄÏìÓ¦Ë ......