Reading integers from a text file with words

后端 未结 6 2025
南笙
南笙 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:32

    fscanf(file, "%*s %d", &num);
    

    or %05d if you have leading zeros and fixed width of 5....

    sometimes the fastest way to do things in C++ is to use C. :)

提交回复
热议问题