sanman10535
Technical User
I have to write a function char *string_replace (char *s, char c, char r) that replaces every instance of character c in string s with character r, and returns the resulting string.
I have created the following main function to test my program. I can change the values sent to the function string_replace to test your program. I will be using my own strings to test the program; so my program should be able to work with any input string.
Can someone help me with the coding for this program? This is what I have so far as for the test program.
The output should be:
The Gctors Are going to bect Floridc Stcte every yecr.
The Gators Are going to beat Florida State every year.
I have created the following main function to test my program. I can change the values sent to the function string_replace to test your program. I will be using my own strings to test the program; so my program should be able to work with any input string.
Can someone help me with the coding for this program? This is what I have so far as for the test program.
Code:
# include <stdio.h>
main () {
char *str = “The Gators Are Going To Beat Florida State Every Year”;
char *result = string_replace (str, ‘a’, ‘c’);
printf (“%s”, result);
result = string_replace (result, ‘c’, ‘a’);
printf (“%s”, result);
}
The output should be:
The Gctors Are going to bect Floridc Stcte every yecr.
The Gators Are going to beat Florida State every year.