Converting c++ string to int

前端 未结 5 1625
天命终不由人
天命终不由人 2021-01-01 06:59

I have the following data in a c++ string

John Doe 01.01.1970

I need to extract the date and time from it into int variables. I tried it li

5条回答
  •  执笔经年
    2021-01-01 07:29

    You need to use

    std::stringstream ss; 
    ss << stringVar;
    ss >> intVar;
    

    or

    intVar = boost::lexical_cast(stringVar);.

    The later is a convenience wrapper from the boost library.

提交回复
热议问题