How to read integers elegantly using C++ stream?

后端 未结 6 1310
醉话见心
醉话见心 2021-01-02 08:52

I have a file full of lines in this format:

1 - 2: 3

I want to only load numbers using C++ streams. Whats the most elegant way to do it? I

6条回答
  •  情话喂你
    2021-01-02 09:21

    I think this one would be the fastest -yet elegant- way:

    int a, b, c;
    scanf("%d-%d:%d", &a, &b, &c);
    

提交回复
热议问题