C++ Converting a String to Double

后端 未结 3 1225
無奈伤痛
無奈伤痛 2020-12-17 03:54

I\'ve been trying to find the solution for this all day! You might label this as re-post but what I\'m really looking for is a solution without using boost lexical c

3条回答
  •  情歌与酒
    2020-12-17 04:30

    If you want to store (to a vector for example) all the doubles of a line

    #include 
    #include 
    #include 
    
    int main()
    {
    
      std::istream_iterator in(std::cin);
      std::istream_iterator eof;
      std::vector m(in,eof);
    
      //print
      std::copy(m.begin(),m.end(),std::ostream_iterator(std::cout,"\n"));
    
    }
    

提交回复
热议问题