void CMy36Dlg::OnButton1()

 CString str1[5]={"12","03","06","3963"}; 
CString str2[3]={"12","06","3963"};
 CString s,p;
for(int x=0;x<4;x++) 
 {        
 for(int j=0;j<2;j++)  
    {
 if(str1[x]=str2[j])
s=str1[x];
}
p=p+s+",";
}
AfxMessageBox(p);
}
代码如上,我的意思是输出相同的字符,应该是12,06这个程序怎么输出是06,06,06,06,小第就是调试不出,求知道的帮我改一下,谢了 VC调试cstring

解决方案 »

  1.   

    其他错误不知道,
    但是if(str1[x]=str2[j])这句一定错了
    比较是两个等号的“==”
      

  2.   



    CString str1[5]={"12","03","06","3963"}; 
    CString str2[3]={"12","06","3963"};
    CString s,p;
    for(int x=0;x<4;x++) 
    {        
    for(int j=0;j<2;j++)  
    {
    if(str1[x]==str2[j])
    {
    s=str1[x];
    p=p+s+",";//相等才加,不相等不加
    }
    }

    }
    AfxMessageBox(p);
     }