What should I use instead of sscanf?

后端 未结 5 2120
南笙
南笙 2020-12-14 16:17

I have a problem that sscanf solves (extracting things from a string). I don\'t like sscanf though since it\'s not type-safe and is old and horrible. I want to be clever and

5条回答
  •  悲哀的现实
    2020-12-14 16:58

    Try std::stringstream:

    #include 
    
    ...
    
    std::stringstream s("123 456 789");
    int a, b, c;
    s >> a >> b >> c;
    

提交回复
热议问题