get a double out a string c++ -
i'm searching efficient way double out of string in c++. cstring double function, can not use because string following format:
double - space - rest of string need save. the problem double can of different sizes, how can double efficiently , still able save rest of string.
use istringstream read double value, ignore 1 character (space expected), , read rest of line.
string s = "1.11 string"; double d; string rest; istringstream iss(s); iss >> d; iss.ignore(); // ignore 1 character, space expected. getline(iss, rest, '\0');
Comments
Post a Comment