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

Çó½Ì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£©ÄÚ´æй©



ÒýÓÃ
¸ßÖÊÁ¿CÁÖÈñ¸½C++Ìâ
£¨1£©Äܹ»Êä³öHelllo World.
£¨2£©ÄÚ´æй©

ûÓÐÊÍ·ÅÄڴ棬ÍüÁË¡£returnÇ°¼ÓÒ»¾ä:
free(str);

ÒýÓÃ
ÎÊÌâ1£ºÍ·Îļþû°üº¬;
ÎÊÌâ2£ºmalloc²ÎÊý´íÎó¡£
ÎÊÌâ3£ºGetMemoryÐèÒª¶þ¼¶Ö¸ÕëÐβΣ¬²ÅÄÜ´ïµ½ÐÞ¸ÄÒ»¼¶Ö¸ÕëµÄÄ¿µÄ.

C/C++ code

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void GetMemory(char **p,int num) //¶þ¼¶Ö¸Õë
{
//p = ¡­¡­


Õý½â...

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


Ïà¹ØÎÊ´ð£º

linux»·¾³ÏÂgethostbynameº¯ÊýÎÊÌâ - C/C++ / CÓïÑÔ

дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
   
  struct hostent *hp; 
char AlarmDevIP[20];  
  int x2;

hp = gethostbyname("www.google.com");
if (hp)
{ ......

C/SÏîÄ¿¼Ü¹¹Éè¼Æ----ÇóÖú - Java / Java SE

±¾ÈËÕýÔÚÓÃJava×öÒ»¸öC/S¼Ü¹¹µÄÏîÄ¿£¬ 
¿ÉÊÇÓÉÓÚÏîÄ¿±È½Ï´ó£¬Ç°ÆڶԼܹ¹µÄÉè¼ÆÓÈÆäÖØÒª£¬ÒòΪºóÆÚ¿ÉÄÜËæʱ»á¼Ó¸ö¹¦ÄÜ»òÕßÈ¥µôijЩ¹¦ÄÜ¡£ 
ËùÒÔÌصØÑ°ÇóÈçºÎÉè¼ÆC/SµÄ¼Ü¹¹Ê¹³ÌÐò¸ü¼ÓÃæÏò¶ÔÏó¸ü¼ÓÒ×ÓÚά ......

Çó½Ìc/c++ÓïÑÔÏà¹ØÎÊÌâ - C/C++ / CÓïÑÔ

ÓÐÒ»10*10¾ØÕ󣬳ýÈ¥µÚÒ»¸öµã£¨0£¬0£©ºÍ×îºóÒ»µã£¨9£¬9£©£¬»¹Óа˸öµãΪ1£¬ÆäËû¶¼Îª0£¬ÒªÇóÓöþάÊý×é±íʾ¡£°Ë¸öµãÊÇËæ»úÉú³ÉµÄ£¬±àдÏà¹Ø³ÌÐò±íʾ¾ØÕóËùÓпÉÄÜÇé¿ö¡£
ÕæÐÄÇó½Ì¸÷λ¸ßÊÖ£¬°¥£¡±¾ÈËÌ«²ËÁË£¡ºÇºÇ£¡
......

¸ÕѧÍêCµÄ»ù´¡£¬ÇóÏÂÒ»²½ - C/C++ / CÓïÑÔ

ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë 
Äã²»Àí½âÖ ......

c ÓïÑÔÀ︡µãÏà³Ë ΪʲôСÊýȫΪ0ÁË - C/C++ / CÓïÑÔ

ÈçÌâ:c ÓïÑÔÀ︡µãÏà³Ë ΪʲôСÊýȫΪ0ÁË
float x=8266.206055;
float y=7226.922363;
float z;
z=x*y;
z=59739228.000000;
ΪʲôµÃµ½µÄZ СÊýµãºóÃæȫΪ0ÁË
ºÇºÇ£¬³¬³ö¸¡µãÄܱíʾ·¶Î§ÁË¡£

Âé·³ÓÐÈËÖªµÀ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ