Encoders
Hub for Computer Whizzes Register to join us

Encoders > More... > C > Program

/* Function squeeze(s,c) to remove a specific character from a string. */

#include <stdio.h>

char squeeze(char string[], char character_to_be_removed);

main()
{
        char a[]="hello world";
	squeeze(a,'o');
	puts(a);
}

char squeeze(char s[], char c)
{
	int i,j;
	for(i=j=0;s[i]!='\0';i++)
		if(s[i]!=c)
			s[j++]=s[i];
	s[j]='\0';
}