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
ÒÔÇ°ÔËÐÐÕâ¸öº¯ÊýµÄʱºòÒ²²»»á³öÏÖÕâÑùµÄ´íÎóµÄ¡£ÕâÊÇʲôÔÒòÄØ£¿{{-
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
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£¬ÒªÇóÓöþάÊý×é±íʾ¡£°Ë¸öµãÊÇËæ»úÉú³ÉµÄ£¬±àдÏà¹Ø³ÌÐò±íʾ¾ØÕóËùÓпÉÄÜÇé¿ö¡£
ÕæÐÄÇó½Ì¸÷λ¸ßÊÖ£¬°¥£¡±¾ÈËÌ«²ËÁË£¡ºÇºÇ£¡
......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
visual c++2008Ëٳɰ棬²»ÄܱàÒëC³ÌÐòÂð£¿Èç¹ûÄÜÊÇÔõô¿ªÊ¼µÄ°¡£¿ÓÃËü´øµÄÃüÁîÌáʾµ¥Ôª³ýÍâ ¡£
н¨¹¤³Ì£¨¿Õ¹¤³Ì»òwin32¿ØÖÆ̨£©
¾ø¶Ô¿ÉÒÔ¡£½¨Á¢win32¿ØÖÆ̨³ÌÐò¾Í¿ÉÒÔ
ÒýÓÃ
н¨¹¤³Ì£¨¿Õ¹¤³Ì»òwin32¿ØÖÆ̨£ ......