infile.open refuses to read the variable in the file
问题 So, I have this loop: int counter1 = 0; ifstream incard; string card; string cardname; stringstream out; while (counter1 < 4) { counter1 = counter1 + 1; out << counter1; out << ".card"; card = out.str(); cout << card; system("PAUSE"); incard.open(card.c_str()); incard >> cardname; cout << cardname << endl; incard.close(); out.str(""); } 1.card contains text "Angel" 2.card contains text "Devil" 3.card contains text "Firaxis" 4.card contains text "Robert" This is the output I get: 1.cardPress