Hi, I'm trying to write a program that reads in a line of text and replaces each 4-letter word with the word "love". If the 4-letter word begins with a capital letter, then the word "Love" shall be used. My program seems to work okay if I use solely 4-letter words in my line of text, but I run into some problems outputting words that aren't 4 letters. Any help would be greatly appreciated! Here's what I've done so far:
void get_input(string& input_line);
// Reads in input_line (line of text) from the user.
string replace_with_love(string input_line);
// Replaces each 4-letter word in input_line with the word "love"
// or "Love", the latter being used if the 4-letter word begins
// with a capital letter.
void intro()
{
cout << "This program reads in a line of text and replaces\n"
<< "each occurrence of a 4-letter word with the word 'love'.\n"
<< "If the 4-letter word begins with a capital letter,\n"
<< "the word 'Love' shall replace it.\n\n";
}
void get_input(string& input_line)
{
string one[SIZE];
int i = 0;
string word;
cout << "Enter a line of text and press return\n"
<< "(no longer than 40 characters, including spaces\n"
<< "and punctuation): ";
getline(cin, input_line);
}
string replace_with_love(string input_line)
{
string one[SIZE];
string love_string(input_line);
string temp;
unsigned int location, location2, count = 0;
unsigned int pos = 0, last = 0;