Hello all, this is the last problem on a hmwk assignment of mine, and I am really getting frustrated over it. I am having probs writing my str_replace function...
Basically, what this program needs to do is the following:
Input sentence : This is very fun.
S (search) = very
R (replace) = not
Output sentence: This is not fun.
This is my thought process for this program:
-have it look through the string you give to the function
-if you find a character that matches the first character of the word to replace then keep checking to see if the whole word is there.
-If it is, then don't add that new word to a temp string, but add the rest and insert the replacement string.
Below is what I have up to now... my replace function may be really wrong, I honestly do not know for sure.... any help would be great. If anyone can walk me through the darn function that would help a lot too, I'm just confused.
#define MAX_LEN 100
int strlen(char *s)
void strcopy(char *x, char *y)
int strcomp(char *x, char *y)
string_replace(char *orig_text, char *search, char *replace)
int *p, *temp, len;
for(i=1; i<=strlen(search); i++)
/* I am really gettin confused w/ this function at this point... how do I start to check character by character, etc? */
char original_str[MAX_LEN], s_str[MAX_LEN], r_str[MAX_LEN], outp_str[MAX_LEN];
printf("New Sentence: %s %s, %s\n", original_str, s_str, r_str);