Hi im attempting to remove a char from a C string, but the output doesnt seem correct. If for example. Input string = "Hello" Specified char to be removed = "l" My output is "HeXXo". I seem to need to push the values in after removing the char?
Code below:
#include <stdio.h>
#include <stdlib.h>
void squeeze(char str[], char c);
void main (){
char input[100];
char c;
printf("Enter string \n");
gets(input);
printf("Enter char \n");
scanf("%c", &c);
printf("char is %c \n", c);
squeeze(input , c );
getchar();
getchar();
getchar();
}
void squeeze(char str[], char c){
int count = 0, i = 0;
while (str[count] != '\0'){
count++;
}
printf("Count = %d \n", count);
for ( i = 0 ; i != count; i++){
if (str[i] == c){
printf("Found at str[%d] \n", i);
str[i] = "";
}
}
printf(" String is = %s", str);
}