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

dz̸CÖеÄmallocºÍfreeº¯Êý

Ò»¡¢malloc()ºÍfree()µÄ»ù±¾¸ÅÄîÒÔ¼°»ù±¾Ó÷¨
1¡¢º¯ÊýÔ­Ðͼ°ËµÃ÷
void *malloc(long NumBytes)£º¸Ãº¯Êý·ÖÅäÁËNumBytes¸ö×Ö½Ú£¬²¢·µ»ØÁËÖ¸ÏòÕâ¿éÄÚ´æµÄÖ¸Õë¡£Èç¹û·ÖÅäʧ°Ü£¬Ôò·µ»ØÒ»¸ö¿ÕÖ¸Õ루NULL£©¡£ ¹ØÓÚ·ÖÅäʧ°ÜµÄÔ­Òò£¬Ó¦¸ÃÓжàÖÖ£¬±ÈÈç˵¿Õ¼ä²»×ã¾ÍÊÇÒ»ÖÖ¡£
void free(void *FirstByte)£º ¸Ãº¯ÊýÊǽ«Ö®Ç°ÓÃmalloc·ÖÅäµÄ¿Õ¼ä»¹¸ø³ÌÐò»òÕßÊDzÙ×÷ϵͳ£¬Ò²¾ÍÊÇÊÍ·ÅÁËÕâ¿éÄڴ棬ÈÃËüÖØеõ½×ÔÓÉ¡£
2¡¢º¯ÊýµÄÓ÷¨
  ÆäʵÕâÁ½¸öº¯ÊýÓÃÆðÀ´µ¹²»ÊǺÜÄÑ£¬Ò²¾ÍÊÇmalloc()Ö®ºó¾õµÃÓù»Á˾Í˦ÁËËü°ÑËü¸øfree()ÁË¡£
    // Code...
    char *Ptr = NULL;
    Ptr = (char *)malloc(100 * sizeof(char));
    if (NULL == Ptr)
   {
       exit (1);
   }
    gets(Ptr);
    // code...
    free(Ptr);
    Ptr = NULL;
µ±È»£¬¾ßÌåÇé¿öÒª¾ßÌå·ÖÎöÒÔ¼°¾ßÌå½â¾ö¡£±ÈÈç˵£¬Ä㶨ÒåÁËÒ»¸öÖ¸Õ룬ÔÚÒ»¸öº¯ÊýÀïÉêÇëÁËÒ»¿éÄÚ´æÈ»ºóͨ¹ýº¯Êý·µ»Ø´«µÝ¸øÕâ¸öÖ¸Õ룬ÄÇôҲÐíÊÍ·ÅÕâ¿éÄÚ´æÕâÏ×÷¾ÍÓ¦¸ÃÁô¸øÆäËûº¯ÊýÁË¡£
3¡¢¹ØÓÚº¯ÊýʹÓÃÐèҪעÒâµÄһЩµØ·½
A¡¢ÉêÇëÁËÄÚ´æ¿Õ¼äºó£¬±ØÐë¼ì²éÊÇ·ñ·ÖÅä³É¹¦¡£
B¡¢µ±²»ÐèÒªÔÙʹÓÃÉêÇëµÄÄÚ´æʱ£¬¼ÇµÃÊÍ·Å£»ÊͷźóÓ¦¸Ã°ÑÖ¸ÏòÕâ¿éÄÚ´æµÄÖ¸ÕëÖ¸ÏòNULL£¬·ÀÖ¹³ÌÐòºóÃ治СÐÄʹÓÃÁËËü¡£
C¡¢ÕâÁ½¸öº¯ÊýÓ¦¸ÃÊÇÅä¶Ô¡£Èç¹ûÉêÇëºó²»ÊͷžÍÊÇÄÚ´æй¶£»Èç¹ûÎÞ¹ÊÊÍ·ÅÄǾÍÊÇʲôҲûÓÐ×ö¡£ÊÍ·ÅÖ»ÄÜÒ»´Î£¬Èç¹ûÊÍ·ÅÁ½´Î¼°Á½´ÎÒÔÉÏ»á³öÏÖ´íÎó£¨ÊÍ·Å¿ÕÖ¸ÕëÀýÍ⣬ÊÍ·Å¿ÕÖ¸ÕëÆäʵҲµÈÓÚɶҲû×ö£¬ËùÒÔÊÍ·Å¿ÕÖ¸ÕëÊͷŶàÉٴζ¼Ã»ÓÐÎÊÌ⣩¡£
D¡¢ËäÈ»malloc()º¯ÊýµÄÀàÐÍÊÇ(void *),ÈκÎÀàÐ͵ÄÖ¸Õ붼¿ÉÒÔת»»³É(void *),µ«ÊÇ×îºÃ»¹ÊÇÔÚÇ°Ãæ½øÐÐÇ¿ÖÆÀàÐÍת»»£¬ÒòΪÕâÑù¿ÉÒÔ¶ã¹ýһЩ±àÒëÆ÷µÄ¼ì²é¡£  
¶þ¡¢malloc()µ½µ×´ÓÄÄÀïµÃÀ´ÁËÄÚ´æ¿Õ¼ä
1¡¢malloc()µ½µ×´ÓÄÄÀïµÃµ½ÁËÄÚ´æ¿Õ¼ä£¿
´ð°¸ÊÇ´Ó¶ÑÀïÃæ»ñµÃ¿Õ¼ä¡£Ò²¾ÍÊÇ˵º¯Êý·µ»ØµÄÖ¸ÕëÊÇÖ¸Ïò¶ÑÀïÃæµÄÒ»¿éÄÚ´æ¡£²Ù×÷ϵͳÖÐÓÐÒ»¸ö¼Ç¼¿ÕÏÐÄÚ´æµØÖ·µÄÁ´±í¡£µ±²Ù×÷ϵͳÊÕµ½³ÌÐòµÄÉêÇëʱ£¬¾Í»á±éÀú¸ÃÁ´±í£¬È»ºó¾ÍÑ°ÕÒµÚÒ»¸ö¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼äµÄ¶Ñ½áµã£¬È»ºó¾Í½«¸Ã½áµã´Ó¿ÕÏнáµãÁ´±íÖÐɾ³ý£¬²¢½«¸Ã½áµãµÄ¿Õ¼ä·ÖÅä¸ø³ÌÐò¡£
  2¡¢Ê²Ã´ÊǶѣº¶ÑÊÇ´ó¼Ò¹²ÓеĿռ䣬·ÖÈ«¾Ö


Ïà¹ØÎĵµ£º

oracle C££ SQL Óï¾ä

ÔÚVSÖÐдSQLÓï¾äµÄʱºò£¬Ç§ÍòÍòǧҪСÐÄÔÙСÐÄ£¬±ÈÈç ˵ Êý¾ÝÀàÐ͵ÄÆ¥Å䣬 µ¥ÒýºÅ£¨Õâ¸öÄÜ°ÑÈËÃÔËÀ£©
 where ×Ó¾äÖпÉǧÍò²»ÄÜÓпոñ£¨µ±²éѯÌõ¼þΪ×Ö·û´®µÄʱºòÄÜ°ÑÄãŪ·è£¬ÎÒŪÕâ¸öµÄʱºò¶¼·èÁ˼¸´ÎÁË£¬Ê²Ã´¶¼¶Ô¾ÍÊDz鲻³öÀ´£¬µ÷ÊÔÁËN±é²Å·¢ÏÖ¡££©²»ÐÐÁË£¬³Ô·¹È¥£¬ÔÙ²»³Ô¿´¼û»îÈ˶¼ÏëÒ§ÁË¡£ ......

C ÔËÐÐʱ´íÎó R6002

ÈçÏ´úÂë±àÒëÔËÐоͻáÌáʾR6002´íÎó #include
struct xxx{
  float score;
};
int main()
{
  xxx* p = new xxx;
  scanf( "%f" , &p->score );
  delete p;
} ½â¾ö·½°¸ºÜ¼òµ¥ int main()
{
  xxx* p ......

C/S ÓëB/S¼Ü¹¹Çø±ðÏê½â£¨×ª£©

Ò»¡¢Ê²Ã´ÊÇC/SºÍB/S
ÒªÏë¶Ô“C/S”ºÍ“B/S”¼¼Êõ·¢Õ¹±ä»¯ÓÐËùÁ˽⣬Ê×ÏȱØÐë¸ãÇå³þÈý¸öÎÊÌâ¡£
µÚÒ»¡¢Ê²Ã´ÊÇC/S½á¹¹¡£
C/S £¨Client/Server£©½á¹¹£¬¼´´ó¼ÒÊìÖªµÄ¿Í»§»úºÍ·þÎñÆ÷½á¹¹¡£ËüÊÇÈí¼þϵͳÌåϵ½á¹¹£¬Í¨¹ýËü¿ÉÒÔ³ä·ÖÀûÓÃÁ½¶ËÓ²¼þ»·¾³µÄÓÅÊÆ£¬½«ÈÎÎñºÏÀí·ÖÅäµ½Client¶ËºÍServer¶ËÀ´Ê ......

µäÐ͵ÄC³ÌÐò´æ´¢¿Õ¼ä²¼¾Ö

Ò»¸öµäÐ͵ÄC³ÌÐò´æ´¢¿Õ¼ä²¼¾ÖÓÉÒÔϼ¸¸ö²¿·Ö×é³É£º
    ÕýÎĶΣºCPUÖ´ÐеÄÖ¸Á·Ö£¬Ò²¾ÍÊÇÖ÷ÒªµÄ³ÌÐò´úÂë±àÒë³öÀ´µÄ½á¹û£¬Ö»¶Á£¬Í¨³£¿ÉÒÔ¹²Ïí¡£
    ³õʼ»¯Êý¾Ý¶Î£ºÍ¨³£³Æ֮ΪÊý¾Ý¶Î£¬°üº¬Á˳ÌÐòÖÐÐèÒªÃ÷È·¸³ÖµµÄ±äÁ¿£¬Æ©ÈçһЩ³õʼ»¯µÄÈ«¾Ö±äÁ¿µÈ£¬Èç int a = 10£¬±äÁ¿ÃûºÍÖµ¶¼´æ·ÅÔÚÕâ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ