Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- int
- main(void){
- int from, to, hmuch;
- std::string buf;
- std::ifstream rFile("data.txt", std::ifstream::in );
- while( std::getline(rFile, buf)){
- /*сплит строки*/
- std::string delim = ":";
- std::string token;
- size_t pos = 0;
- pos = buf.find(delim);
- token = buf.substr(0, pos);
- from = atoi(token.c_str());
- buf.erase(0, pos + delim.length());
- pos = buf.find(delim);
- token = buf.substr(0, pos);
- to = atoi(token.c_str());
- buf.erase(0, pos + delim.length());
- pos = buf.find(delim);
- token = buf.substr(0, pos);
- hmuch = atoi(token.c_str());
- buf.erase(0, pos + delim.length());
- std::cout << from << std::endl;
- std::cout << to << std::endl;
- std::cout << hmuch << std::endl;
- std::cout << "***\n";
- }
- rFile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement