In: Computer Science
3.24 LAB C++ : Program: Text message decoder
(1) Use getline() to get a line of user input into a string.
Output the line. (3 pts)
Ex:
Enter text: IDK if I'll go. It's my BFF's birthday. You entered: IDK if I'll go. It's my BFF's birthday.
(2) Search the string (using find()) for common abbreviations and
print a list of each found abbreviation along with its decoded
meaning. (3 pts)
Ex:
Enter text: IDK if I'll go. It's my BFF's birthday. You entered: IDK if I'll go. It's my BFF's birthday. BFF: best friend forever IDK: I don't know
Support these abbreviations:
pls help this is so confusing!!
Please find your solution below and if any doubt or need change comment.And do upvote.
CODE:
#include <iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    int index;
    //take input using getline
    cout<<"Enter text:"<<endl;
    getline(cin,str,'\n');
    cout<<"You entered: "<<str<<endl;
    
    //using find() function find if these  string 
    //are present or not 
    index = str.find( "BFF", 0 );
    if( index != string::npos )
    {
       cout<<"BFF: best friend forever\n";
    }
    index = str.find( "IDK", 0 );
    if( index != string::npos )
    {
       cout<<"IDK: I don\'t know\n";
    }
    index = str.find( "JK", 0 );
    if( index != string::npos )
    {
       cout<<"JK: just kidding\n";
    }
    index = str.find( "TMI", 0 );
    if( index != string::npos )
    {
       cout<<"TMI: too much information\n";
    }
    index = str.find( "TTYL", 0 );
    if( index != string::npos )
    {
       cout<<"TTYL: talk to you later\n";
    }
    return 0;
}
OUTPUT:
