c语言,去除字符串中重复的字母,求助~

#include "stdafx.h"
#include "stdio.h"
int _tmain(int argc, _TCHAR* argv[])
{
#define size 1000
void deleteRepeats(char []);
char message[size];
printf("Please enter a sentence:\n");
gets(message);
deleteRepeats(message);
return 0;
}
void deleteRepeats(char string[])
{
char a,b;
int i,j;
i=0;
for(i;i!=' ';i++)
{
a=string[i];
for(j=i+1;j!=' ';j++)
{
b=string[j];
if(a==b)
{
string[j]=' ';
}
else
{
;
}
}
}
int string2[1000];
int z,x;
x=0;
for(z=0;string[z]!='\0';z++)
{
if(string[z]!=' ')
{
string2[x]=string[z];
x++;
}
else
{
;
}
}

printf("%s",string2);
}

哪里错了,为什么输入什么都只出现第一个字母???

#include "stdafx.h"
#include "stdio.h"
int _tmain(int argc, _TCHAR* argv[])
{
#define size 1000
void deleteRepeats(char []);
char message[size];
printf("Please enter a sentence:\n");
gets(message);
deleteRepeats(message);
return 0;
}
看你上面,你建的工程有问题,弄一个普通的win32控制台程序即可,不要mfc这些东西。注:mfc是微软针对windows窗口编程提供的类库集合。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-11-17
gets(message);

这个换成:scanf("%s", message);
相似回答