fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. string s = "28tech hoc lap trinh";
  9. //Khai báo stringstream ss và gán cho nó nội dung của s
  10. stringstream ss(s);
  11. string word;
  12. int dem = 0;
  13. while(ss >> word){
  14. ++dem;
  15. cout << "Tu thu " << dem << " tach duoc : " << word << endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Tu thu 1 tach duoc : 28tech
Tu thu 2 tach duoc : hoc
Tu thu 3 tach duoc : lap
Tu thu 4 tach duoc : trinh