cĬÈÏÊÇ´«ÖµµÄ
ÔÚcÖУ¬²ÎÊýĬÈÏÊÇ´«ÖµµÄ£¬¼´ÔÚ²ÎÊýÈëջʱ±»¸´ÖÆÒ»·Ý
¡£ÔÚº¯ÊýÀïÃæÐÞ¸ÄÕâЩ²ÎÊý£¬²»»áÓ°ÏìÍâÃæµÄµ÷ÓÃÕß¡£
ÀýÈç
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void get_str(char * p)
{
p = (char *)malloc(sizeof("abcd"));
strcpy(p , "abcd");
return ;
}
int main()
{
char * p = NULL;
get_str(p);
printf("p = %p\n", p);
return 0;
}
·ÖÎö£º
ÔÚmainº¯ÊýÀïÃæ³õʼ»¯Ö¸ÕëpλnuLL£¬ËäÈ»get_strº¯ÊýÊǽÓÊܵÄÖ¸Õ룬°´ÕÕÉÏÃæµÄ˵·¨£¬ÎÒÃÇÔÚÕ»Öи´ÖƵÄÊÇpÖ¸ÏòÄÚÈݵĵØÖ·£¬´«¸øº¯Êýget_str£¬ÔÚº¯ÊýÀïÃæÎÒÃÇÓÖÖØÐÂÐÞ¸ÄÁËÕâ¸öµØÖ·£¬¶ø²»ÊÇÐÞ¸ÄÕâ¸öµØÖ·µÄÄÚÈÝ£¬¹ÊÍâÃæ¾Í²»Æð×÷Óá£
Ïà¹ØÎĵµ£º
±àÒëNative CµÄhello,worldÄ£¿é
Android ±àÒë»·¾³±¾Éí±È½Ï¸´ÔÓ£¬ÇÒ²»ÏñÆÕͨµÄ±àÒë»·¾³£ºÖ»Óж¥²ãĿ¼Ï²ÅÓÐMakefileÎļþ£¬¶øÆäËûµÄÿ¸öcomponent¶¼Ê¹ÓÃͳһ±ê×¼µÄ Android.mk. Android.mkÎļþ±¾ÉíÊDZȽϼòµ¥µÄ£¬²»¹ýËü²¢²»ÊÇÎÒÃÇÊìϤµÄMakefile£¬¶øÊǾ¹ýÁËAndroid×ÔÉí±àÒëϵͳµÄºÜ¶à´¦Àí£¬Òò´ËÒªÕæÕýÀ ......
exercise2.4
void squeeze(char s[],char t[])
{
int i,j,k;
int lens,lent;
lens=strlen(s);
lent=strlen(t);
for(i=0,k=0;i<lens;i++)
{
for(j=0;j<lent;j++)
if(s[i]==t[j])
break;
if(j==lent)
s[k++]=s[i];
}
s[k]='\0';
}
exercise2.5
int any(char s[],char t[ ......
cÔËÐпâmalloc·ÖÅäµÄÄÚ´æÔÚÄÄÀïÄØ£¬Ê×ÏÈÉÏ´úÂ룺
//ÄÚ´æ´óСÁ¬½ÓÆ÷½«ÆäµØÖ·Ö¸Ïò-heapÑ¡Ïî
extern _DATA_ACCESS int _SYSMEM_SIZE;
//ÄÚ´æÇøÓò
#pragma DATA_SECTION(_sys_memory, ".sysmem")
far PACKET _sys_memory[1] = { ((size_t)&_SYSMEM_SIZE) - sizeof(PACKET), 0 };
  ......
12.1 λÔËËã·û£ÃÓïÑÔÌṩÁËÁùÖÖλÔËËã·û£º
& °´Î»Óë
| °´Î»»ò
^ &nb ......
ÎÒÓõÄÊÇubuntu²Ù×÷ϵͳ¡£´ò¿ªÖÕ¶Ë
1.sudo apt-get install vim(vim-full Õâ¸öÈí¼þ×Ô9.10°æ±¾±»·ÏÆúÁË£¬²»ÂÛÔõôÌí¼ÓÈí¼þÔ´¶¼ÕÒ²»µ½µÄ£¬ËùÒÔÖ±½Ó°²×°vim¾Í¿ÉÒÔÁË£¬£¬Ò²¿ÉÒÔ°²×°gvim£¬£¬ÔÚÐÂÁ¢µÃÈí¼þÀïÃæËÑË÷vim¾Í¿ÉÒÔÕÒµ½ÁË)
2.
sudo apt-get install build-essential // build-essentialÊÇcÓïÑԵĿª·¢°ü£¬°üº¬ÁËgcc ma ......