I'm trying to build a function in C that changes the characters 'f' and/or 'o' of a string to 'x'. For some reason I keep getting a segmentation fault (core dumped) when i run the program, even though it compiles without issue. I understand that a segmentation fault occurs when the program tries to access a location in memory that it doesn't have access to, however, I don't see what in my code could be causing this issue. here's my code:
#include <stdio.h>
void censor(char p[]);
int main(){
    censor("foodfool");
    return 0;
}
void censor(char p[]){
    int i;
    for(i = 0;p[i] != '\0';i++){
        if(p[i] == 'f' || p[i] == 'o')
            p[i] = 'x';
        printf("%c", p[i]);     
    }
    printf("\n");
}
 
     
    