Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void getInput(char * inFile)
- {
- enum direction_t {NORTH, SOUTH};
- direction_t direction;
- enum priority_t {HIGH, LOW};
- priority_t priority;
- string line;
- ifstream inFile(inFile);
- if(!inFile.good())
- {
- cerr << "can't open input file";
- exit(1);
- }
- while(getline(inFile, line))
- {
- char first = line.at(0);//first letter signifies direction and priority
- if(first == 'n')
- {
- direction = NORTH;
- priority = LOW;
- }
- else if(first == 'N')
- {
- direction = NORTH;
- priority = HIGH;
- }
- else if(first == 's')
- {
- direction = SOUTH;
- priority = LOW;
- }
- else if(first == 'S')
- {
- direction = SOUTH;
- priority = HIGH;
- }
- else
- {
- cerr << "invalid direction given: " << first << endl;
- //exit(1);
- }
- size_t commaIndex = line.find(",", 2);//know first character is letter, second is comma
- string firstNumber = line.substr(2, commaIndex-2);
- string secondNumber = line.substr(commaIndex+1, line.length());
- cout << "firstNumber: " << firstNumber << " secondNumber " << secondNumber << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement