Çó½ÌC¸ßÊÖ£¬Ò»ÌâcÓïÑÔ³ÌÐò×÷Òµ£¡ - C/C++ / CÓïÑÔ
ÏÂÃæÒ»¶Î³ÌÐò»á²úÉúʲô½á¹û£¿ÎªÊ²Ã´£¿
void GetMemory(char *p,int num)
{
p = (char *)malloc(sizeof(char),num);
return;
}
int main()
{
char *str = NULL;
GetMemory(&str,100);
strcpy(str,"Helllo World.");
printf(str);
return 0;
}
¸ßÖÊÁ¿CÁÖÈñ¸½C++Ìâ
£¨1£©Äܹ»Êä³öHelllo World.
£¨2£©ÄÚ´æй©
ûÓÐÊÍ·ÅÄڴ棬ÍüÁË¡£returnÇ°¼ÓÒ»¾ä:
free(str);
Õý½â...
C/C++ code:
void GetMemory(char *p,int num)
{
p = (char *)malloc(sizeof(char) * num); // Õâ¶ùÓ¦¸ÃÊÇ*°É¡£
return;
}
int main()
{
char *str = NULL; // Õâ¾äÏ൱ÓÚconst char* str = NULL; str ²»¿É±ä¡£
GetMemory(str,100); //Õâ¾ästr»¹ÊÇNULL¡£
strcpy(str,"Helllo World.");
printf(str);
return 0;
}
C/C++ c
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
±¾ÈËÕýÔÚÓÃJava×öÒ»¸öC/S¼Ü¹¹µÄÏîÄ¿£¬
¿ÉÊÇÓÉÓÚÏîÄ¿±È½Ï´ó£¬Ç°ÆڶԼܹ¹µÄÉè¼ÆÓÈÆäÖØÒª£¬ÒòΪºóÆÚ¿ÉÄÜËæʱ»á¼Ó¸ö¹¦ÄÜ»òÕßÈ¥µôijЩ¹¦ÄÜ¡£
ËùÒÔÌصØÑ°ÇóÈçºÎÉè¼ÆC/SµÄ¼Ü¹¹Ê¹³ÌÐò¸ü¼ÓÃæÏò¶ÔÏó¸ü¼ÓÒ×ÓÚά ......
ÓÐÒ»10*10¾ØÕ󣬳ýÈ¥µÚÒ»¸öµã£¨0£¬0£©ºÍ×îºóÒ»µã£¨9£¬9£©£¬»¹Óа˸öµãΪ1£¬ÆäËû¶¼Îª0£¬ÒªÇóÓöþάÊý×é±íʾ¡£°Ë¸öµãÊÇËæ»úÉú³ÉµÄ£¬±àдÏà¹Ø³ÌÐò±íʾ¾ØÕóËùÓпÉÄÜÇé¿ö¡£
ÕæÐÄÇó½Ì¸÷λ¸ßÊÖ£¬°¥£¡±¾ÈËÌ«²ËÁË£¡ºÇºÇ£¡
......
ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë
Äã²»Àí½âÖ ......
ÈçÌâ:c ÓïÑÔÀ︡µãÏà³Ë ΪʲôСÊýȫΪ0ÁË
float x=8266.206055;
float y=7226.922363;
float z;
z=x*y;
z=59739228.000000;
ΪʲôµÃµ½µÄZ СÊýµãºóÃæȫΪ0ÁË
ºÇºÇ£¬³¬³ö¸¡µãÄܱíʾ·¶Î§ÁË¡£
Âé·³ÓÐÈËÖªµÀ ......