Coolquest, Inc. Home Products Support About Contact
cbold_logo_gif C++BOLD Reference Manual cbold_logo_gif

<<< Previous CBOLD Reference Home Next >>>

 

12.2. CSTRING/SCSTRING

CSTRING() is a utility for forming a char* using stream-like syntax.

The char* points to a null-terminated character array and is valid forever, i.e., it behaves just like a char* created using quoted text.

In the example below, MyPointer will point to "Foo1Bar", then "Foo2Bar", then "Foo3Bar".

for ( int i = 1; i <= 3; ++ i ) {
  char* MyPointer = CSTRING( "Foo" << i << "Bar" );
  ...
}

Standard ostream manipulators may be used with CSTRING(), e.g., to control formatting. The loop below sets reference bases of M00, M01, ..., M15:

for ( int i = 0; i < 16; ++ i ) {
  MyModules[ i ].SetReferenceBase( CSTRING( "M" << setw( 2 ) << setfill( '0' ) << i ) );
  ...
}

SCSTRING() is similar to CSTRING, but it uses only a single static location to store the string. The returned char* is valid only until the next call of SCSTRING().

 

<<< Previous CBOLD Reference Home Next >>>

Legal Copyright © 2007 by Coolquest, Inc. Contact