源文件是C格式的,用的是C++,还必须要转化为C格式才行。
代码:
int GetResult(const char *input, char *output)
{
if (NULL==input || NULL==output)
{
return -1;
}
string str;
int len = strlen(input);
if (len==0)
{
return -1;
}
for (int i=0; i<len; ++i)
{
str.push_back(input[i]);
}
set<char> recorder;
for (string::iterator it=str.begin(); it!=str.end();)
{
if (!recorder.count(*it))
{
recorder.insert(*it);
it++;
}
else
{
it = str.erase(it);
}
}
int newlen = str.size();
for (int i=0; i<newlen; ++i)
{
output[i] = str[i];
cout << str[i];
}
output[newlen] = '\0';
return 0;
}
int main()
{
char a[]="asdasd";
char *p = a;
char *res = NULL;
GetResult(p,res);
return 0;
}