1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
int main()
{
char cPhrase[]={'I',' ','l','o','v','e',' ','e','a','t','i','n','g',' ',
'a','l','l',' ','k','i','n','d','s',' ','o','f',' ','d','e','s','s','e','r','t','s','.','\0'};
std::istringstream buf(cPhrase);
std::vector<std::string> cString;
char delim = 'e';
for(std::string word; getline(buf, word, delim); )
cString.push_back(word + delim);
for(size_t i=0; i<cString.size(); ++i)
std::cout << '"' << cString[i] << "\" ";
}
|