Question: My code has a segmentation fault which I can't figure out why. #include #include #include char* alphabets(char string[]){ char *new_string; for(int i = 0;string[i]!='0';i++){ if(isalpha(string[i])){

 My code has a segmentation fault which I can't figure out

My code has a segmentation fault which I can't figure out why.

#include #include #include

char* alphabets(char string[]){ char *new_string;

for(int i = 0;string[i]!='\0';i++){ if(isalpha(string[i])){ new_string[i]=string[i]; } }

return new_string; }

int main() { char test[]="Hello, World!"; char *new_arra=alphabets(test); printf("%s",new_arra); printf(" ");

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!