Format
Format and store a series of characters and values in the string.
void Format( LPCSTR lpcszFormat, ... )
none.
EX1
void string_Format_ex1() { char sz[10] = "abcdefg"; int nn = 10; double dd = 3.1416; string str; str.Format("Results = %s, %d, %5.4f", sz, nn, dd); out_str(str);//Results = abcdefg, 10, 3.1416 }
EX2
// the following usage will generate runtime error due to // incorrect data being used void string_Format_ex2() { string str; str.Format("x1=%f, x2=%f", 5, 3.4); // 5 is not a double, will generate runtime error str.Format("x1=%f, x2=%f", 5.0, 3.4);// this will work correctly }
This member function formats and stores a series of characters and values in the string. Each optional argument (if any) is converted and output according to the corresponding format specification in lpcszFormat. Please note that it is your responsibility to match the data type with the correct formatting specification.
printf
origin.h