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

dz̸CÄÚ´æ·ÖÅä2

 ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
£¨1£© ´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄ
Õû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static ±äÁ¿¡£
£¨2£© ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯
ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ´¦ÀíÆ÷µÄÖ¸Á
ÖУ¬Ð§Âʺܸߣ¬µ«ÊÇ·ÖÅäµÄÄÚ´æÈÝÁ¿ÓÐÏÞ¡£
£¨3£© ´Ó¶ÑÉÏ·ÖÅ䣬Òà³Æ¶¯Ì¬ÄÚ´æ·ÖÅä¡£³ÌÐòÔÚÔËÐеÄʱºòÓÃmalloc »ònew ÉêÇëÈÎÒâ¶à
ÉÙµÄÄڴ棬³ÌÐòÔ±×Ô¼º¸ºÔðÔÚºÎʱÓÃfree »òdelete ÊÍ·ÅÄÚ´æ¡£¶¯Ì¬ÄÚ´æµÄÉú´æÆÚ
ÓÉÎÒÃǾö¶¨£¬Ê¹Ó÷dz£Áé»î£¬µ«ÎÊÌâÒ²×î¶à¡£
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str£¬ "hello world");
printf(str);
}
ÇëÎÊÔËÐÐTest º¯Êý»áÓÐʲôÑùµÄ½á¹û£¿
´ð£º³ÌÐò±ÀÀ£¡£
ÒòΪGetMemory ²¢²»ÄÜ´«µÝ¶¯Ì¬Äڴ棬
Test º¯ÊýÖÐµÄ str Ò»Ö±¶¼ÊÇ NULL¡£
strcpy(str£¬ "hello world");½«Ê¹³ÌÐò±À
À£¡£
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
ÇëÎÊÔËÐÐTest º¯Êý»áÓÐʲôÑùµÄ½á¹û£¿
´ð£º¿ÉÄÜÊÇÂÒÂë¡£
ÒòΪGetMemory ·µ»ØµÄÊÇÖ¸Ïò“Õ»ÄÚ´æ”
µÄÖ¸Õ룬¸ÃÖ¸ÕëµÄµØÖ·²»ÊÇ NULL£¬µ«ÆäÔ­
ÏÖµÄÄÚÈÝÒѾ­±»Çå³ý£¬ÐÂÄÚÈݲ»¿ÉÖª¡£
void GetMemory2(char **p£¬ int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str£¬ 100);
strcpy(str£¬ "hello");
printf(str);
}
ÇëÎÊÔËÐÐTest º¯Êý»áÓÐʲôÑùµÄ½á¹û£¿
´ð£º
£¨1£©Äܹ»Êä³öhello
£¨2£©ÄÚ´æй©
void Test(void)
{
char *str = (char *) malloc(100);
strcpy(str£¬ “hello”);
free(str);
if(str £¡= NULL)
{
strcpy(str£¬ “world”);
printf(str);
}
}
ÇëÎÊÔËÐÐTest º¯Êý»áÓÐʲôÑùµÄ½á¹û£¿
´ð£º´Û¸Ä¶¯Ì¬ÄÚ´æÇøµÄÄÚÈÝ£¬ºó¹ûÄÑÒÔÔ¤
ÁÏ£¬·Ç³£Î£ÏÕ¡£
ÒòΪfree(str);Ö®ºó£¬str ³ÉΪҰָÕ룬
if(str £¡= NULL)Óï¾ä²»Æð×÷Óá£
******************


Ïà¹ØÎĵµ£º

c/sÓëb/sµÄ²»Í¬

C/SÊÇClient/ServerµÄËõд¡£·þÎñÆ÷ͨ³£²ÉÓøßÐÔÄܵÄPC¡¢¹¤×÷Õ¾»òСÐÍ»ú£¬²¢²ÉÓôóÐÍÊý¾Ý¿âϵͳ£¬ÈçOracle¡¢Sybase¡¢Informix»ò SQL Server¡£¿Í»§¶ËÐèÒª°²×°×¨ÓõĿͻ§¶ËÈí¼þ¡£
B/S ÊÇBrower/ServerµÄËõд£¬¿Í»§»úÉÏÖ»Òª°²×°Ò»¸öä¯ÀÀÆ÷£¨Browser£©£¬ÈçNetscape Navigator»òInternet Explorer£¬·þÎñÆ÷°²×°Oracle¡¢Sybase¡¢In ......

C ÖÐtypedefµÄһЩʹÓÃ

1. »ù±¾½âÊÍ
¡¡¡¡typedefΪCÓïÑԵĹؼü×Ö£¬×÷ÓÃÊÇΪһÖÖÊý¾ÝÀàÐͶ¨ÒåÒ»¸öÐÂÃû×Ö¡£ÕâÀïµÄÊý¾ÝÀàÐÍ°üÀ¨ÄÚ²¿Êý¾ÝÀàÐÍ£¨int,charµÈ£©ºÍ×Ô¶¨ÒåµÄÊý¾ÝÀàÐÍ£¨structµÈ£©¡£
¡¡¡¡ÔÚ±à³ÌÖÐʹÓÃtypedefÄ¿µÄÒ»°ãÓÐÁ½¸ö£¬Ò»¸öÊǸø±äÁ¿Ò»¸öÒ×¼ÇÇÒÒâÒåÃ÷È·µÄÐÂÃû×Ö£¬ÁíÒ»¸öÊǼò»¯Ò»Ð©±È½Ï¸´ÔÓµÄÀàÐÍÉùÃ÷¡£
¡¡¡¡ÖÁÓÚtypedefÓÐʲô΢ÃîÖ®´ ......

Windows via C/C++£ºÏ̵߳÷¶È——¸ÅÊö

»ùÓÚÓÅÏȼ¶µÄ²Ù×÷ϵͳ£¨preemptive operating system£©±ØÐëʹÓÃijÖÖËã·¨ÒÔ¾ö¶¨CPUÈçºÎµ÷¶ÈϵͳÖеÄỊ̈߳¬±¾Õ½«ÌÖÂÛWindows VistaʹÓõĵ÷¶ÈËã·¨¡£ ÎÒÃÇ֮ǰÌÖÂÛ¹ýÏ̵߳ÄÉÏÏÂÎĽṹCONTEXT£¬ÆäÖк¬ÓÐÏß³Ì×îºóÒ»´ÎÖ´ÐÐʱCPU¼Ä´æÆ÷×éµÄ״̬¡£ ²Ù×÷ϵͳÿ20ºÁÃë¼ì²éϵͳÖÐËùÓÐÏß³ÌÄں˶ÔÏóµÄ״̬£¬ÆäÖÐһЩ¶ÔÏó±»ÈÏΪÊǿɵ÷¶È£ ......

C/C++º¯ÊýÉùÃ÷ºÍº¯Êý¶¨ÒåÖ®²»Í¬£¨Àý½â£©


º¯Êý - ÉùÃ÷¡¢¶¨Òå¡¢µ÷ÓÃ
¡¡¡¡1. Èç¹ûº¯ÊýûÓÐÉùÃ÷, Ó¦¸ÃÔÚµ÷ÓÃÇ°¶¨Òå:
#include¡¡<stdio.h>
/*¡¡¶¨ÒåÇó´óÖµº¯Êý¡¡*/
int¡¡MAX(int¡¡x,¡¡int¡¡y)¡¡{
¡¡¡¡if¡¡(x¡¡>¡¡y)
¡¡¡¡¡¡¡¡return¡¡x;
¡¡¡¡else
¡¡¡¡¡¡¡¡return¡¡y;
}¡¡
/*¡¡¶¨ÒåÇóСֵº¯Êý¡¡*/
int¡¡MIN(int¡¡x,¡¡int¡¡y)¡¡{
¡¡¡¡return¡¡x¡¡&l ......

c/c++ÃæÊÔÌâ

½ñÌìÈ¥ÃæÊÔÒ»¼Ò¹«Ë¾£¬ÌîÁËÒ»·Ý“»§¿Úµ÷²é”£¬È»ºó¾ÍÊÇ×öÒ»·ÝÃæÊÔÌ⣬ÌâÄ¿ºÜ¼òµ¥
1¡¢¸Ä´íÌ⣬¸øÒ»¶Î³ÌÐò£¬Ö¸³ö´íÎó
2¡¢Socket×èÈûºÍ·Ç×èÈû±à³Ì£¬·Ç×èÈûµÄʵÏÖÔ­Àí
3¡¢TCP/IPÓëOSIÆß²ãÄ£ÐÍ
TCP/IP²Î¿¼Ä£Ð͹²ÓÐÎå²ã£ºÓ¦Óò㡢´«Êä²ã¡¢»¥ÁªÍø²ãºÍÖ÷»úÖÁÍøÂç²ã¡£
ÓëOSI²Î¿¼Ä£ÐÍÏà±È£¬TCP/IP²Î¿¼Ä£ÐÍûÓбíʾ²ãºÍ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ