2013-01-25 229 views
0

正在使用此功能返回值不正確

int spc_email_isvalid(const char *address) { 


int  count = 0; 
const char *c, *domain; 
static char *rfc822_specials = "()<>@,;:\\\"[]"; 

/* first we validate the name portion ([email protected]) */ 
for (c = address; *c; c++) { 
if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == 
    '\"')) { 
    while (*++c) { 
    if (*c == '\"') break; 
    if (*c == '\\' && (*++c == ' ')) continue; 
    if (*c <= ' ' || *c >= 127) return 0; 
    } 
    if (!*c++) return 0; 
    if (*c == '@') break; 
    if (*c != '.') return 0; 
    continue; 
} 
if (*c == '@') break; 
if (*c <= ' ' || *c >= 127) return 0; 
if (strchr(rfc822_specials, *c)) return 0; 
} 
if (c == address || *(c - 1) == '.') return 0; 

/* next we validate the domain portion ([email protected]) */ 
if (!*(domain = ++c)) return 0; 
do { 
if (*c == '.') { 
    if (c == domain || *(c - 1) == '.') return 0; 
    count++; 
} 
if (*c <= ' ' || *c >= 127) return 0; 
if (strchr(rfc822_specials, *c)) return 0; 
} while (*++c); 

return (count >= 1); 
} 

當我所有的函數AfxMessageBox的(spc_email_isvalid( 「[email protected]」));它返回null

如何讓基於電子郵件ID

+1

有關使用調試器是什麼? – sharptooth

回答

1

AfxMessageBox需求LPCTSTR作爲第一個參數值0或1:

CString str;  
str.Format(_T("%d"), spc_email_isvalid("[email protected]")); 

AfxMessageBox(str, MB_OK | MB_ICONINFORMATION); 
+0

非常感謝您的幫助。解決了它 – user1858925