ubuntu ϵĵÚÒ»¸öC³ÌÐò
ʹÓà gcc ÔÚ ubuntu Ï ±àÒë Ò»¸ö C³ÌÐò £º
µÚÒ»²½Ö裺´ò¿ª ÖÐ¶Ë £¨Õâ¸ö ÖªµÀ°É£¿£©
ÊäÈë sudo gedit no.c (no.cΪCÎļþÃû×Ö)
sudo ±íʾÄãÊäÈëµÄÃüÁî¾ßÓйÜÀíԱȨÏÞ
gedit ±íʾÄãÒª±à¼Ò»¸öÎļþ
on.c¾ÍÊÇÄãÒª±à¼µÄÎļþÁËŶ£¬Èç¹û¸ÃÎļþ²»´æÔÚ£¬ÏµÍ³»áн¨Ò»¸öÎļþµÄ
µÚ¶þ²½Ö裺ÊäÈëC´úÂë²¢±£´æ£¨²»ÒªÓÐÓï·¨´íÎóŶ£©
µÚÈý²½Ö裺ÊäÈë sudo gcc -o no no.c ÕâÑù¾Í»á½øÐбàÒ룬Èç¹û±àÒë³É¹¦Á˾ͽøÐÐÏÂÒ»²½£¬·ñÔò¼ì²é
ÄãµÄ´úÂëÊÇ·ñÓÐ´í £»sudo µÄÒâ˼ºÍÉÏÃæÒ»Ñù ; gccÊDZíʾÓÃGCC±àÒëÆ÷±àÒë ; £o ÊÇÉú³ÉÄ¿±ê
Îļþ £»no ÊÇÄãÒªÉù³ÆµÄÄ¿±êÎļþµÄÃû×Ö£»no.cÊÇÔ´Îļþ£¨¾ÍÊÇÓÃÀ´Éù³ÆÄ¿±êÎļþµÄÔ´Îļþ£©
µÚËIJ½Ö裺Èç¹ûûÓдíÎó£¬Ö´ÐÐ ÕâÒ»¸ö²½Ö裺 ./no ±íʾÔËÐбàÒëºÃµÄÎļþ
ºÃÁË£¬ÒÔÉ϶¼ÊÇÎÒ³õѧ UBUNTUµÄÐĵà ÈçÓÐÀí½â²»¶ÔµÄ£¬ÇëÖ¸³öŶ £¡
Ïà¹ØÎĵµ£º
N µ±ÓÃÁ½¸ö²¹Âë±íʾµÄ´ø·ûºÅÊý½øÐÐÔËËãʱ£¬N=1±íʾÔËËãµÄ½á¹ûΪ¸ºÊý£»N=0±íʾÔËËãµÄ½á¹ûΪÕýÊý»òÁã.
Z Z=1±íʾÔËËãµÄ½á¹ûΪÁ㣬Z=0±íʾÔËËãµÄ½á¹û·ÇÁã¡£
C ¿ÉÒÔÓÐ4ÖÖ·½·¨ÉèÖÃCµÄÖµ£º
¼Ó·¨ÔËË㣨°üÀ¨CMN£©£ºµ±ÔËËã½á¹û²úÉúÁ˽øλʱ£¨ÎÞ·ûºÅÊýÒç³ö£©£¬C=1£¬·ñÔòC=0¡£
¼õ·¨ÔËË㣨°üÀ¨CMP£©£ºµ±ÔËËãʱ²úÉúÁ˽èλʱ£¨ÎÞ·ûºÅÊ ......
@ ECHO OFF
@ ECHO.
@ ECHO. ˵ Ã÷
@ ECHO ----------------------------------------------------------------- ......
#include <iostream.h>
void fun0(int* p)
{
int* a=new int[3];
*a=0;
*(a+1)=1;
*(a+2)=2;
p=a;
}
void fun1(int* &p)
{
int* a=new int[3];
*a=0;
*(a+1)=1;
*(a+2)=2;
p=a;
}
void fun2(int* p)
{
*p=0;
*(p+1)=1;
*(p+2)=2;
}
//warning:returning address of local va ......
֪ʶ½á¹¹:
1¡¢if,for,switch,goto
2¡¢#define,const
3¡¢Îļþ¿½±´µÄ´úÂë,¶¯Ì¬Éú³ÉÄÚ´æ,¸´ºÏ±í´ïʽ,strcpy,memcpy,sizeof
4¡¢º¯Êý²ÎÊý´«µÝ,ÄÚ´æ·ÖÅ䷽ʽ,ÄÚ´æ´íÎó±íÏÖ,mallocÓënewÇø±ð
5¡¢ÀàÖØÔØ¡¢Òþ²ØÓ븲¸ÇÇø±ð,externÎÊÌâ,º¯Êý²ÎÊýµÄȱʡֵÎÊÌâ,ºê´úÂëÓëÄÚÁªº¯ÊýÇø±ð
6¡¢¹¹ÔìºÍÎö¹¹µÄ´ÎÐò,Stringº¯Êý¶¨Òå
¾ß ......
1.¶¯Ì¬»ñµÃÄÚ´æµÄ´úÂë:
void GetMemory(char **p, int num)
{
*p = (char *)malloc(sizeof(char) * num);
}
char* GetMemory2(int num)
{
char* p = (char *)malloc(sizeof(char) * num);
return p;
}
------------------------------------------
´íÎóµÄ´úÂë:
void Ge ......