Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <sstream>
- #include <fstream>
- using namespace std;
- std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
- std::stringstream ss(s);
- std::string item;
- while (std::getline(ss, item, delim)) {
- elems.push_back(item);
- }
- return elems;
- }
- std::vector<std::string> split(const std::string &s, char delim) {
- std::vector<std::string> elems;
- split(s, delim, elems);
- return elems;
- }
- ///BMW;X4;2001;5000;565;1500
- int main()
- {
- //cout << "Hello world!" << endl;
- std::vector<std::string> x = split("Nikola;Nikolic;1234567891011", ';');
- for(int i = 0; i < x.size(); i++){
- // cout << x[i] << endl;
- }
- std::ifstream file("podaci.txt");
- std::string str;
- while (std::getline(file, str))
- {
- std::vector<std::string> x = split(str, ';');
- cout << "Marka bona:" << x[0] << endl;
- cout << "Model je cekaj covjece:" << x[1] << endl;
- cout << "Ovaj bona auto sam kupio lijepog leta:" << x[2] << endl;
- cout << "Uspjio sam se icenjkat za cijenu od:" << x[3] << endl;
- cout << "Mnogo jako cudo covjcece ima Mororinskih snaga:" << x[4] << endl;
- cout << "Moz u njega sipat volko litari:" << x[5] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement