Xavax C++ Library | Class Index FAQ Overview |
Constructor Summary |
CStringFormatter(char* buffer,
unsigned int size, bool terminate)
Construct a CStringFormatter object. |
Methods Inherited From Formatter | |
print,
print
|
Related Classes | |
Formatter, Variant |
Constructor Detail |
CStringFormatter(char* buffer, unsigned int size,
bool terminate)
buffer
- the output buffer.size
- the buffer size.terminate
-
true if the output should be terminated with a null character.Example Code |
#include <iostream.h> #include "CStringFormatter.h" int main(int argc, char** argv) { // // Declare some local variables to demonstrate the data // types supported by CStringFormatter. // const char* s = "Hello World"; bool b = true; int i = 1234; unsigned int ui = 32767; double d = 1.2345; // // Declare a formatter for a character buffer. // char buffer[128]; CStringFormatter cstf(buffer, sizeof(buffer), true); // // The format string prints a boolean, an integer, two // unsigned integers, a floating point value, and a string. // const char* format = "bool b = %b;\n" "int i = %d;\n" "uint ui = %u;\n" "uint ui = %x;\n" "double d = %f;\n" "char* s = %s;\n"; // // Each of the variables b, i, ui, d, and s will be // converted to a Variant and passed to print. // cstf.print(format, b, i, ui, ui, d, s); cout << "result: " << buffer; return 0; }
Copyright © 2003 Xavax Inc. -- All Rights Reserved