Advertisement
kernel_memory_dump

Untitled

Mar 21st, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <sstream>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
  10.     std::stringstream ss(s);
  11.     std::string item;
  12.     while (std::getline(ss, item, delim)) {
  13.         elems.push_back(item);
  14.     }
  15.     return elems;
  16. }
  17.  
  18.  
  19. std::vector<std::string> split(const std::string &s, char delim) {
  20.     std::vector<std::string> elems;
  21.     split(s, delim, elems);
  22.     return elems;
  23. }
  24. ///BMW;X4;2001;5000;565;1500
  25. int main()
  26. {
  27.     //cout << "Hello world!" << endl;
  28.     std::vector<std::string> x = split("Nikola;Nikolic;1234567891011", ';');
  29.  
  30.     for(int i = 0; i < x.size(); i++){
  31.       //  cout << x[i] << endl;
  32.     }
  33.  
  34.     std::ifstream file("podaci.txt");
  35.     std::string str;
  36.     while (std::getline(file, str))
  37.     {
  38.         std::vector<std::string> x = split(str, ';');
  39.  
  40.         cout << "Marka bona:" << x[0] << endl;
  41.         cout << "Model je cekaj covjece:" << x[1] << endl;
  42.         cout << "Ovaj bona auto sam kupio lijepog leta:" << x[2] << endl;
  43.         cout << "Uspjio sam se icenjkat za cijenu od:"  << x[3] << endl;
  44.         cout << "Mnogo jako cudo covjcece ima Mororinskih snaga:" << x[4] << endl;
  45.         cout << "Moz u njega sipat volko litari:" << x[5] << endl;
  46.  
  47.  
  48.  
  49.     }
  50.  
  51.  
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement