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

C/C++Ö¸ÕëºÍÊý×éµÄʹÓúÍÇø±ð

        
³£¼ûµÄÄÚ´æ·ÖÅäºÍʹÓôíÎó
1) ÄÚ´æµÄÉêÇëºÍ·ÖÅ䲢ûÓгɹ¦£¬µ«³ÌÐòԱȴʹÓÃÁËËü¡£Ò»Ð©ÐÂÊÖ¾­³£»á·¸ÕâÖÖ´íÎó£¬ËûÃDz¢²»»áÁôÒâµ½ÄÚ´æûÓзÖÅä³É¹¦¡£ÅжÏÖ¸ÕëµÄÖµÊÇ·ñΪNULL¿ÉÒÔÓÐЧµØ±ÜÃâÕâÖÖ´íÎó¡£
2) ÄÚ´æµÄ·ÖÅäÒѾ­³É¹¦£¬µ«ÊÇȴûÓнøÐгõʼ»¯¾ÍÖ±½ÓʹÓÃËüÁË¡£Ê×ÏÈÊǹÛÄîÉϵÄÎÊÌ⣬ºÜ¶àÈ˶¼Ã»ÓÐÔÚʹÓÃÖ¸ÕëÇ°Òª³õʼ»¯ÕâÑùµÄÏ°¹ß£¬È»¶øÕâ¸öÏ°¹ßÈ´ÊǺÜÖØÒªµÄ£¬Ï£Íû´ó¼ÒÒ»¶¨ÒªÇ¿ÆÈ×Ô¼ºÑø³É¡£µÚ¶þ¾ÍÊÇÖ÷¹ÛµØÈÏΪ×Ô¼ºÉêÇëµÄÄÚ´æµÄȱʡֵΪ0£¬ÕâÑùÏëÊÇûÓÐʲôµÀÀíµÄ£¬ÄÚ´æ·ÖÅäºóµÄÖµÊDz»È·¶¨µÄ¡£
3) ÉÏÃæµÄÁ½ÖÖ¹¤×÷¶¼ÒѾ­×öºÃÁË£¨ÒѾ­³É¹¦ÉêÇë²¢³õʼ»¯Íê³É£©£¬µ«ÊDzÙ×÷ʱȴԽ½çÁË¡£
4) ÉêÇëÁËÄڴ棬ʹÓÃÍêÁËÈ´Íü¼ÇÁËÊÍ·Å£¬µ¼ÖÂÄÚ´æй¶¡£ÕâÑùµÄ´íÎó¿ÉÒÔÐÎÈÝΪһ¸ö¶ñÐÔµÄÖ×Áö£¬Ëü²»»áÂíÉÏÒªÄãµÄÃü£¬µ«ÊÇËü»áÂýÂýµØÍÌÊÉÄãµÄϵͳ×ÊÔ´£¬Ö±µ½ÄãµÄ³ÌÐò³¹µ×Íêµ°¡£
5) ÄãºÜСÐĵØÊÍ·ÅÁËÄڴ棬µ«ÊÇÈ´ÓÖʹÓÃÁËËü¡£ÓÉÓÚ³ÌÐòºÜ¸´ÔÓ»òÕßµ÷ÓÃ˳Ðò³ö´í£¬ÕâÑù¿ÉÄܵ¼Ö³öÏÖÉÏÃæµÄ´íÎó¡£
Ö¸Õë---Ò»°Ñΰ´óµÄË«Èн£
ÎÒÕæµÄ·Ç³£Åå·þ·¢Ã÷Ö¸ÕëµÄÈË£¬Ëû¼òֱ̫ΰ´óÁË¡£ÄÜʹÓÃÈç´Ë¼ò½àµØ·½·¨½«¸´ÔÓµÄÄÚ´æ½á¹¹ÃèÊöµÄÈç´ËÇå³þ£¬Õâ±¾Éí¾ÍÊÇÒ»ÖÖΰ´óµÄ³É¾Í¡£µ«ÊÇ£¬Ö¸ÕëÖ®ÓÚ³ÌÐòÔ±ÈçͬÎäÆ÷Ö®ÓÚÊ¿±ø£¬ÓúÃÁË¿ÉÒÔÍþÁ¦Îޱȣ¬Óò»ºÃÔòº¦È˺¦¼º¡£
ÎÒÏÈ˵˵ָÕëºÍÊý×éµÄÇø±ð¡£Êý×éÃû¶ÔÓ¦×ÅÒ»¿éÄڴ棬ËüµÄµØÖ·¡¢ÈÝÁ¿ÔÚÆäÉúÃüÖÜÆÚÖÐÊDz»¿É±äµÄ£¬Ö»ÓÐÊý×éÄÚÈÝÊǿɱäµÄ¡£Ö¸Õë¿ÉËæʱָÏòÈκÎÀàÐ͵ÄÄڴ棬ËüµÄÌصã¾ÍÊÇ“±ä”¡£Ö¸ÕëÔ¶±ÈÊý×éÁé»î£¬µ«Ò²¸üΣÏÕ¡£
Êý×éÃûÊDz»ÄÜÖ±½Ó½øÐи³ÖµºÍ±È½ÏµÄ¡£Èç¹ûÄãÏòÒª½«Êý×éa¸³Öµ¸øÊý×éb£¬²»ÄÜÖ±½ÓÓø³ÖµÓï¾äb = a £¬ÕâÑù»áÁî±àÒëÆ÷²úÉú´íÎóµÄ¡£±ØÐëʹÓñê×¼µÄ¿âº¯ÊýstrcpyÀ´½øÐи³Öµ¡£ÏàͬµØ£¬Òª±È½ÏaºÍbµÄÄÚÈÝÊÇ·ñÏàͬ£¬²»ÄÜʹÓÃÆÕͨµÄÂß¼­ÅжÏif£¨b==a£©£¬Ò²ÒªÓ¦Óÿ⺯ÊýstrcmpÀ´Åжϡ£
//Êý×é……
        char *p = (char *)malloc(100);
strcpy(p, “hello”);
free(p); // the address of “p” is not changed.
….
if (NULL != p) //it will return TRUE
strcpy(p, “world”); //Wrong!!!
 
ÔÚ¼ÆËãÄÚ´æÈÝÁ¿µÄʱºòÓÐÒ»µãÊDZØÐëÒªÖ¸³öµÄ£¬ÄǾÍÊÇsizeof¼ÆËãÊý×éÊǼÆËãËüµÄʵ¼ÊµÄÄÚ´æÈÝÁ¿£¬¶ø¼ÆËãÖ¸ÕëʱÔòÓÀÔ¶¶¼ÊÇ4¸ö×Ö½Ú¡£C++ÊÇÓÀԶûÓа취֪µÀÖ¸ÕëËùÖ¸µÄÄÚ´æÈÝÁ¿£¬³ý·


Ïà¹ØÎĵµ£º

C/C++:³ÌÐòµÄÄÚ´æ·ÖÅ䷽ʽ Alvin

1.ÄÚ´æ·ÖÅ䷽ʽ
¡¡¡¡ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
¡¡¡¡[1]´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
¡¡¡¡[2]ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ ......

c/c++ ¾²Ì¬±äÁ¿ Ò»¸öʵÀý

#include <iostream>
#include <cstdlib>
using namespace std;
class Foo
{
public:
Foo(int ii):i(ii){}
int getInt(){return i;}
private:
int i;
};
class Bar
{
public:
static int FooVal(){c++; return f.getInt();}
int callsFooVal(){return c;}
private:
s ......

¡¾JavaÍøÂç±à³ÌÒ»¡¿Ò»¸ö¼òµ¥µÄc/s³ÌÐò

ʵÑéÒªÇó£º
1.±àд»ùÓÚTCPЭÒéµÄͨÐųÌÐò£¬°üÀ¨ServerÓëClientÁ½¸ö²¿·Ö¡£ÊµÏÖ»ØÉù³ÌÐò£º¼´¿Í»§¶Ë·¢ËÍÏûÏ¢£¬·þÎñÆ÷¶Ë½«ÊÕµ½µÄÏûÏ¢Ô­Ñù»áË͸ø¿Í»§¶Ë¡£
2.ÔÚµ¥»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»
3.ÔÚ¶à»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»£¨ChatServerÖ»ÐèÔËÐÐÔÚһ̨Ö÷»úÉÏ£¬ChatClient¿ÉÔÚÆäËüÖ÷»úÉÏÔËÐУ¨ÒªÖªµÀChatServerËùÔ ......

c ÓïÑÔÖеĴ«ÖµÓë´«ÒýÓÃ


#include<stdio.h>
int cubeByValue(int n);
int main(){
    int number = 5 ;
    printf("The original value of number is %d\n",number);
    number = cubeByValue(number);   
    printf("The new  ......

ͨ¹ý#pragma pack(n)¸Ä±äC±àÒëÆ÷µÄ×Ö½Ú¶ÔÆ뷽ʽ

Ô­ÎĵØÖ·£ºhttp://blog.csdn.net/yc0188/archive/2005/02/26/303190.aspx
ÔÚCÓïÑÔÖУ¬½á¹¹ÊÇÒ»ÖÖ¸´ºÏÊý¾ÝÀàÐÍ£¬Æä¹¹³ÉÔªËؼȿÉÒÔÊÇ»ù±¾Êý¾ÝÀàÐÍ£¨Èçint¡¢long¡¢floatµÈ£©µÄ±äÁ¿£¬Ò²¿ÉÒÔÊÇһЩ¸´ºÏÊý¾ÝÀàÐÍ£¨ÈçÊý×é¡¢½á¹¹¡¢ÁªºÏµÈ£©µÄÊý¾Ýµ¥Ôª¡£ÔڽṹÖУ¬±àÒëÆ÷Ϊ½á¹¹µÄÿ¸ö³ÉÔ±°´Æä×ÔÈ»¶Ô½ç£¨alignment£©Ìõ¼þ·ÖÅä¿Õ¼ä¡£¸÷ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ