Std :: Oststream vs std :: ostringstream

xiaoxiao2021-03-06  19

Test std :: Oststream and std :: Ostringstream with the following block, you can find std :: oststream with memory leaks, it is best to use std :: ostringstream.

Std :: ostringstream OS, OSS2; Std :: String Strval; Double Var = 200.03234; // Read Triple Decimal Oss.Setf (ios :: Fixed, ios :: Floatfield); OSS.PRecision (3); OSS < <(double) VAR << '/ 0'; double dblval = 0; std :: istringstream ISS (oss.str ()); ISS >> dblval; // To drop the mantissa 0 OSS2 << std :: setPrecision (15 << DBLVAL << '/ 0'; strval = oss2.str (). C_str ();

转载请注明原文地址:https://www.9cbs.com/read-42137.html

New Post(0)