Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm having trouble traversing an init file. It doesnt look like its even entering the while loop. Here is my function:
void intializeRoute( string filename, Route& route )
{
ifstream fin;
// fin.open( filename.data() );
fin.open (filename.data(), fstream::binary);int i = 0;
string currentWord = "test";
cout << currentWord;
getchar();
while(fin >> currentWord)
{
if(currentWord.compare("!=") == 0)
if(currentWord.compare("=") == 0)
if(currentWord.compare("=!") == 0)
{
cout << "COMMENT" << endl;
string routeComment;
getline(fin, routeComment);
}
else if(currentWord.compare("TradingPost") == 0)
{
string name;
getline(fin, name);
name.erase(0, 1);
route.addTradingPost(name);
cout << "Trading Post Added" << endl;
getchar();
}
else if(currentWord.compare("Merchant") == 0) {
string merchName;
int currency;
fin >> merchName >> currency;
route.addMerchant(merchName, currency);
}
else if(currentWord.compare("Description") == 0) {
string desc;
getline( fin, desc );
desc.erase( 0, 1 );
route.addGoodDescription(desc);
}
else if(currentWord.compare("Good") == 0) {
string goodName;
int value;
fin >> value;
getline(fin, goodName);
goodName.erase(0, 1);
route.addGood(goodName, value);
}
else if(currentWord.compare("Arrangement") == 0) {
string tpDest, type;
int cost;
fin >> type >> cost;
getline(fin, tpDest);
tpDest.erase(0, 1);
route.addTravArrange(tpDest, type, cost);
}
else
cout << "Bad line in script" << endl;
i++;
}
fin.close();cout << i;
getchar();
}Those extraneous couts and getchars are for testing purposes.
Any ideas?
Igor

I was just wondering if you live in the Texas DFW area, I have a friend at my school named Igor ( not trying to be mean in any way ) and it dosnt seem that popular of a name, I was wondeirng if you were him ^_^ cause that would be awesome if I knew someone who was into programming and comps like me :)
anywho ill look through your code and see what I can do, but I just figured id ask ya this anyways :)
understandable if you dont want to tell me anything.
GIMPS

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |