Help with a simple code!

I need help. My code is as follows. It outputs the correct statement I need on another program. But on the program I am trying to submit it to, it won't compile due to my int not being unsigned and string::npos being in my code. Help!

#include <iostream>
#include <string>
using namespace std;

int main() {

string userInput;
int userText = 0;

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

cout << "You entered: " + userInput << endl;

userText = userInput.find("BFF");
while (userText != string::npos){
userInput.replace(userText, 3, "best friend forever");
userText = userInput.find("BFF");
}

userText = userInput.find("IDK");
while (userText != string::npos){
userInput.replace(userText, 3, "I don't know");
userText = userInput.find("IDK");
}

userText = userInput.find("JK");
while (userText != string::npos){
userInput.replace(userText, 2, "just kidding");
userText = userInput.find("JK");
}

userText = userInput.find("TMI");
while (userText != string::npos){
userInput.replace(userText, 3, "too much information");
userText = userInput.find("TMI");
}

userText = userInput.find("TTYL");
while (userText != string::npos){
userInput.replace(userText, 4, "talk to you later");
userText = userInput.find("TTYL");
}

cout << "Expanded: " << userInput << endl;

return 0;
}
Last edited on
Topic archived. No new replies allowed.