some-usable-scripts/c/squeeze.c

31 lines
420 B
C
Raw Normal View History

2011-02-03 13:47:29 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void squeeze( char *s, char *t, char c );
int main(int argc, char **argv)
{
char s[10];
char t[10];
scanf("%s",s);
squeeze(s,t,'a');
printf("%s\n",t);
}
void squeeze( char *s , char *t, char c)
{
int i = 0;
int k = 0;
while( s[i] != '\n' && s[i] != '\0' )
{
if (s[i] != c && k < strlen(t))
{
t[k] = s[i];
k++;
}
i++;
}
t[k]='\0';
}