#include "stdio.h"
void squeeze(char s[], int c);
/* main: removes all occurrences of the character c from a string s*/
int main()
{
char c;
// char str[];
char str[] = "This is a c programs ";
printf ("The original string is: %s\n", str);
while ((c = getchar()) != EOF)
squeeze(str, c);
printf("Now thw string is: %s\n", str);
return 0;
}
/* squeeze: delete all c from s */
void squeeze(char s[], int c)
{
int i, j;
for (i = j = 0; s[i] !='\0'; i++)
if (s[i] != c)
s[j++] = s[i];
s[j] = '\0';
}
阅读(315) | 评论(0) | 转发(0) |