Reading integers from a text file with words

后端 未结 6 2032
南笙
南笙 2020-12-12 01:48

I\'m trying to read just the integers from a text file structured like this....

ALS 46000
BZK 39850
CAR 38000
//....

using ifstream.

<
6条回答
  •  生来不讨喜
    2020-12-12 02:34

    why to make simple things complicated?

    whats wrong in this :

    ifstream ss("C:\\test.txt");
    
    int score;
    string name;
    while( ss >> name >> score )
    {
        // do something with score
    }
    

提交回复
热议问题