1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
int main()
{
std::ifstream inFile("txtSample.txt");
std::string userInput;
std::string line;
int geoID = 0;
int xCoord = 0;
int yCoord = 0;
int wood = 0;
int clay = 0;
int iron = 0;
int stone = 0;
int food = 0;
int specID = 0;
int comID = 0;
int regID = 0;
std::cout << "Enter the letter n for a newline,"
<< " or enter anything else to quit."
<< std::endl;
std::cin >> userInput;
while (std::getline(inFile, line))
{
std::istringstream tokenizer(line);
std::getline(tokenizer, geoID, '|' );
std::getline(tokenizer, xCoord, '|');
std::getline(tokenizer, yCoord, '|');
std::getline(tokenizer, wood, '|');
std::getline(tokenizer, clay, '|');
std::getline(tokenizer, iron, '|');
std::getline(tokenizer, stone, '|');
std::getline(tokenizer, food, '|');
std::getline(tokenizer, specID, '|');
std::getline(tokenizer, comID, '|');
std::getline(tokenizer, regID);
}
}
|