#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
void Squeeze(char s[],char c);
int main()
{
char str[20],ch;
printf_s("input a string:");
gets_s(str);
printf_s("input a character:");
ch = getchar();
Squeeze(str,ch);
printf_s("Results:%s\n",str);
system("pause");
return 0;
}
void Squeeze(char s[],char c)
{
int i,j;
for(i=j=0;s[i] != ‘\0‘;i++)
{
if(s[i] != c)
{
s[j] = s[i];
j++;
}
}
s[j] = ‘\0‘;
}
时间: 2024-09-19 13:38:41