Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string html;
- //(Some code that reads into a big string)
- string delimiter( "<p class="wx-temp">" );
- vector<int> temperatures;
- size_t pos = html.find_first_of(delimiter);
- while( pos != string::npos )
- {
- // Skip past the tag (to the temperature)
- pos += delimiter.size();
- if( pos >= html.size() ) break;
- // Extract it (C-style) and chuck it into the vector.
- int temperature = atoi( html.c_str() + pos );
- temperatures.push_back(temperature);
- // If you want to stop after the first 10:
- if( temperatures.size() == 10 ) break;
- // Find the next tag
- pos = html.find_first_of(delimiter, pos);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement