void strip_out(char *str) {
int length_string = strlen(str);
//printf("%d\n", length_string);
char temp[length_string];
int i = 0;
int j = 0;
while ((*(str + i) != '\0')) {
if (isalpha(str[i])) {
//printf("yes\n");
*(temp + j) = *(str + i);
i++;
j++;
}
else {
//printf("No\n");
i++;
}
}
I need my *str value to be changed to the value of temp so i can use it in another function.
I cannot change the return type, if i could I could just return temp but it has to be void.
If you want to change a string in place removing all non alpha characters then there is no need to define an auxiliary array.
The function can look the following way as it is shown in the demonstration program below.
The program output is
If you want to create a new string based on the passed argument then the function can look the following way as it is shown in the next demonstrative program.
The program output is the same as shown above