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

cʵÏֵĶÁ´óÎļþ·½·¨£¨Ô´´úÂ룩


static char *file2memory(FILE *file, long *size)
{
  char buffer[1024];
  char *string=NULL;
  char *newstring=NULL;
  long len=0;
  long stringlen=0;
  if(file) {
    while((len = fread(buffer, 1, sizeof(buffer), file))) {
      if(string) {
        newstring = (char*)realloc(string, len+stringlen+1);
        if(newstring)
          string = newstring;
        else
          break; /* no more strings attached! :-) */
      }
      else
        string = (char*)malloc(len+1);
      memcpy(&string[stringlen], buffer, len);
      stringlen+=len;
    }
    if (string) {     
      string[stringlen] = 0;
    }
    *size = stringlen;
    return string;
  }
  else
    return NULL; /* no string */
}


Ïà¹ØÎĵµ£º

C/C++ÖÐStaticµÄ×÷ÓÃÏêÊö


C/C++ÖÐStaticµÄ×÷ÓÃÏêÊö
 
1.ÏÈÀ´½éÉÜËüµÄµÚÒ»ÌõÒ²ÊÇ×îÖØÒªµÄÒ»Ìõ£ºÒþ²Ø¡£
µ±ÎÒÃÇͬʱ±àÒë¶à¸öÎļþʱ£¬ËùÓÐδ¼Óstaticǰ׺µÄÈ«¾Ö±äÁ¿ºÍº¯Êý¶¼¾ßÓÐÈ«¾Ö¿É¼ûÐÔ¡£ÎªÀí½âÕâ¾ä»°£¬ÎÒ¾ÙÀýÀ´ËµÃ÷¡£ÎÒÃÇҪͬʱ±àÒëÁ½¸öÔ´Îļþ£¬Ò»¸öÊÇa.c£¬ÁíÒ»¸öÊÇmain.c.
ÏÂÃæÊÇa.cµÄÄÚÈÝ£º
char a = 'A'; // global variable
void ......

Keil C51 vs ±ê×¼C

ÉîÈëÀí½â²¢Ó¦ÓÃC51¶Ô±ê×¼ANSICµÄÀ©Õ¹ÊÇѧϰC51µÄ¹Ø¼üÖ®Ò»¡£ÒòΪ´ó¶àÊýÀ©Õ¹¹¦Äܶ¼ÊÇÖ±½ÓÕë¶Ô8051ϵÁÐCPUÓ²¼þµÄ¡£´óÖÂÓÐÒÔÏÂ8 Àࣺ 8051´æ´¢ÀàÐͼ°´æ´¢ÇøÓòl;  ´æ´¢Ä£Ê½l´æ´¢Æ÷ÀàÐÍÉùÃ÷l±äÁ¿ÀàÐÍÉùÃ÷l λ±äÁ¿ÓëλѰַl  ÌØÊ⹦ÄܼĴæÆ÷(SFR)l C51Ö¸Õël  º¯ÊýÊôÐÔ¾ßÌå˵Ã÷ÈçÏÂ(8031ΪȱʡCPU)¡£
µÚÒ»½Ú Keil C ......

C/C++ µÄÈ«¾Ö±äÁ¿³õʼ»¯Óë²»³õʼ»¯µÄÇø±ð

ÔÚCÓïÑÔÀȫ¾Ö±äÁ¿Èç¹û²»³õʼ»¯µÄ»°£¬Ä¬ÈÏΪ0£¬Ò²¾ÍÊÇ˵ÔÚÈ«¾Ö¿Õ¼äÀ
int x =0; ¸ú int x; µÄЧ¹û¿´ÆðÀ´ÊÇÒ»ÑùµÄ¡£µ«ÆäʵÕâÀïÃæµÄ²î±ðºÜ´ó£¬Ç¿ÁÒ½¨Òé´ó¼ÒËùÓеÄÈ«¾Ö±äÁ¿¶¼Òª³õʼ»¯£¬ËûÃǵÄÖ÷Òª²î±ðÈçÏ£º
±àÒëÆ÷ÔÚ±àÒëµÄʱºòÕë¶ÔÕâÁ½ÖÖÇé¿ö»á²úÉúÁ½ÖÖ·ûºÅ·ÅÔÚÄ¿±êÎļþµÄ·ûºÅ±íÖУ¬¶ÔÓÚ³õʼ»¯µÄ£¬½ÐÇ¿·ûºÅ£¬Î´³õʼ»¯µÄ ......

̸CÖÐscanfÏÝÚå

Ô­ÎĵØÖ·£ºhttp://westsoftware.blog.163.com/blog/static/2609410920091953456841/
      ×î½üÒ»Ö±ÔÚ¿´Andrew KoeningдµÄÊé¼®£¬¿ÉÒÔ˵ѧϰC/C++»òÕß´ÓÊÂÕâ·½ÃæµÄ¿ª·¢µÄÈËÔ±·Ç³£ÖµµÃÒ»¿´µÄÊé¼®£¬ÕâÀïÎÒÍƼö¿´¿´¡¶CÏÝÚåÓëȱÏÝ¡·Ó롶C/C++³Á˼¼¡·¡£
      ÕâÀïÏÈÀ´¿´¿ ......

¾Ý˵ÊÇÃÀ¹ú×î¡°¹Ö¡±C³ÌÐò´óÈüµÄ»ñ½±³ÌÐò

int main()
{
printf(&unix["\021%six\012\0"], (unix)["have"] + "fun" - 0x60);
}
gcc -S±àÒë³É»ã±à´úÂëÈçÏÂ:
        .file   "test.c"
        .section        .rodata
.LC0:
&nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ