I am trying to replace an abbreviation in a line of text with the meaning written out..

I think I need to take out the pos >= 0, and use "if (pos != string::npos) { " but not even sure what that means. Here is what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
using namespace std;

int main() {
  string tweet;
  unsigned int pos;
  

  cout << "\nEnter tweet:"; // User enters a complete tweet (160 characters or less)
  getline(cin, tweet);  // Gets the single line of text
  tweet.resize(160);  // Resizes to 160 characters
 
  
  pos = tweet.find("LOL");
  if (pos >= 0) {	                                              // Note: This expression asks: Does the tweet have "LOL" anywhere?
     tweet.replace(pos, 3, " laughing out loud ");
  }
 
Why did you create a second thread for this topic?
I thought it didn't go through the first time. Sorry about that.
Topic archived. No new replies allowed.