All pastes #94291 Raw Edit

Stuff

public cpp v1 · immutable
#94291 ·published 2006-07-21 03:48 UTC
rendered paste body
// CS246 Assignment 4// Matt Rusiniak - 20178167// July 20, 2006#include <iostream>#include <fstream>#include <string>//#include <Controller.h>using namespace std;int main () {	ifstream rfile;	string filename, linein, state, service, input;	int i = 0, flag = 0, pos = 0;	// continue until we receive stop to terminate the loop	while (filename != "stop") {		cin >> filename;		rfile.open(filename.c_str());		// loop through each line of the input file		while (!rfile.eof()) {			getline(rfile, linein);						if (linein.size() == 0) break;			flag = 0, pos = 0, i = 0;						// loop through input searching for a space						while (flag != 1) {												if (linein[i] == ' ') {					// we found our space delimiter					pos++;					// now based on where we were, we are reading a different variable					switch (pos) {						case 1:						state = linein.substr(0,i);						break;						case 2:						service = linein.substr(state.size() + 1, (i - state.size() - 1));						break;						case 3:						input = linein.substr(i - 1);						// When flag = 1, we should break out of the while loop that is going through each line, and go to the next line						flag = 1;						break;											} // close switch													} // close if								i++;			} // close while			// THIS IS WHERE WE WILL PASS THE VARIABLES TO THE CONTROLLER					}		// close the file, move on to next input		rfile.close();	}	return 0;}