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

return ·¢Éú access violation ´íÎó - C/C++ / CÓïÑÔ

ÕâÊÇÎҵĴúÂëC/C++ code:

{
boolean bresult = FALSE;
AECHAR wMaoHao = ':';
AECHAR* waddress;
AECHAR* ptemp = NULL;
AECHAR* ptemp2 = accessAddress;
char* pstrtemp;
uint16 uport = 0;

ptemp = WSTRCHR(accessAddress, wMaoHao);

if (!ptemp)
{
*pwaddress = NULL;
*pwport = NULL;
return;
}

waddress = (AECHAR *) MALLOC( sizeof(AECHAR) * (ptemp - accessAddress + 1) );
if (waddress)
{
AECHAR * pa1 = waddress;
while(ptemp2 != ptemp)
{
*waddress = *ptemp2;
++ waddress;
++ ptemp2;
}
if (ptemp2 == ptemp)
{
*waddress = 0;
}

waddress = pa1;
}

pstrtemp = (char *) MALLOC( sizeof(char) * WSTRLEN( ++ptemp ) + 1 );
if (pstrtemp)
{
WSTRTOSTR(ptemp, pstrtemp, sizeof(char) * WSTRLEN( ptemp ) + 1);
uport = ATOI(pstrtemp);
}

*pwaddress = waddress;
*pwport = uport;

}



ΪºÎ Ò»µ½ return ¾Í²úÉú access violation ?
ÎÒÓõÄÊÇVC6.0
ÒÔǰÔËÐÐÕâ¸öº¯ÊýµÄʱºòÒ²²»»á³öÏÖÕâÑùµÄ´íÎóµÄ¡£ÕâÊÇʲôԭÒòÄØ£¿{{-


Ïà¹ØÎÊ´ð£º

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

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

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

Ϊʲôxml²»ÄÜÏÔʾ°¢À­²®ÎÄ - C/C++ / C++ ÓïÑÔ

ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À­²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À­²®ÎĵÄ×Ö¿âÄãÓÐô£¿

ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......

visual c++2008²»ÄܱàÒëC³ÌÐòÂð - C/C++ / CÓïÑÔ

visual c++2008Ëٳɰ棬²»ÄܱàÒëC³ÌÐòÂð£¿Èç¹ûÄÜÊÇÔõô¿ªÊ¼µÄ°¡£¿ÓÃËü´øµÄÃüÁîÌáʾµ¥Ôª³ýÍâ ¡£
н¨¹¤³Ì£¨¿Õ¹¤³Ì»òwin32¿ØÖÆÌ¨£©

¾ø¶Ô¿ÉÒÔ¡£½¨Á¢win32¿ØÖÆÌ¨³ÌÐò¾Í¿ÉÒÔ

ÒýÓÃ
н¨¹¤³Ì£¨¿Õ¹¤³Ì»òwin32¿ØÖÆÌ¨£ ......

ÓйØAccessÊý¾Ý¿â´æÈ¡µÄÎÊÌâ - C++ Builder / »ù´¡Àà

ÈçºÎ½«Ò»¸öListBoxÖеÄÊý¾Ý´æÔÚÊý¾Ý¿âÖеÄÒ»¸ö×Ö¶ÎÏÂÃæ£¬²¢ÇÒÿÌõ¼Ç¼µÄ×Ö·û´®¸öÊý²»Ò»¶¨ ÒÔ¼°ÈçºÎ´ÓÊý¾Ý¿âÖжÁÈ¡¸ÃListBoxÖеÄËùÓмǼ
C/C++ code:

//´æÈëÊý¾Ý¿â
void __fastcall TForm1::Button5Click(TO ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ