Question: I am trying to write a function that deletes a char c from a string src, and I am getting a seg fault when I try to run it. Here is the function.

```
void removeChar(char *src, char c){
  int i, j = 0;
  int size;
  char ch1;
  char str1[100];

  size = strlen(src);

  for (i = 0; i < size; i++){
    if (src[i] != c){
      ch1 = src[i];
      str1[j] = ch1;
      j++;
    }
  }
  str1[j] = '\0';
  src = str1;
}

```

And here is the main function where I am calling it.

```
int main(int argc, char **argv){
    char *str = "Hello, world!\0";
    printf("%s\n", removeChar(str, 'l'));
}

```

Answer: 
the return type of this function `removeChar(str, 'l')` is void not an char array and you are passing this to 

> 
> printf("%s\n", removeChar(str, 'l'));
> 
> 
> 

so here %s may give you the segmentation fault.
You can print the string in the function itself! Then it works:

```
#include <stdio.h>
#include <string.h>

void removeChar(char src[], char c){
  int i, j = 0;
  int size;
  char ch1;
  char str1[100];

  size = strlen(src);

  for (i = 0; i < size; i++) {
    if (src[i] != c) {
      ch1 = src[i];
      str1[j] = ch1;
      j++;
    }
  }
  str1[j] = '\0';
  src = str1;

  printf("%s\n", src);

}

int main(int argc, char **argv) {

    char str[] = "Hello, world!";
    removeChar(str, 'l');

    return 0;

}

```