Text decoder

I cant figure out how to expand. Output the line again, this time expanding common text message abbreviations.

[code]
#include <iostream>
#include <string>
using namespace std;

int main() {
string userInput;

cout << "Enter text: " << endl;
getline (cin, userInput);
cout << "You entered: " << userInput << endl;


return 0;
}
First of all, you'll need a table, which contains abbr. and its actual text message.
After that, you'll have to break the input into words, and replace the occurrences of abbr. with actual text message.

pseudo code
1
2
3
4
5
6
7
8
9
10
getline(cin, userInput);
words = split_to_words(userInput);
for (const auto &word : words) {
    if (found_in_abbr_table(word)) {
        cout << actual_text(word)
    }
    else {
        cout << word
    }
}

Topic archived. No new replies allowed.