有什么方法可以判断字符串中有没有相同的字符?
比如说字符串"ABCDEAFBG"里有两个A,两个B
我想把重复的A和B都去掉一个,得到字符串"ABCDEFG"
有什么好的方法实现吗?
小弟实在没想明白 如果一个一个字符的查太麻烦了......对了,VC中有什么有这种功能的函数吗?谢谢啦!

解决方案 »

  1.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vclrfCStringTTrim.asp
      

  2.   

    我这个是用mfc类的CString的。还是比较高效率的:#include <afx.h>
    #include <iostream.h>int main(){
    CString str = "ABCDEAADBBFFE";
    cout<<"Before check:\n"<<str<<endl;
    for(int i=0;i<str.GetLength();i++)
    {
    if(str.Find(str[i],0) < i){
    str.Delete(i);
    i--;
    }
    }
    cout<<"After check:\n"<<str<<endl;
    return 0;
    }