Export (0) Print
Expand All
Expand Minimize


Call this function to copy a string into a fixed size character buffer.

template <class T>
inline bool SafeStringCopy(
      T& Destination,
   const char* Source 
) throw( );



A fixed size character buffer of type char[Size] (not char*).


The buffer to which the data should be copied.


The null-terminated string containing the data to be copied.

Returns TRUE if all of Source was copied to Destination, FALSE if the data was truncated.

The function is safe because it will not compile if type T is not a fixed size character buffer and if type T is a fixed size buffer, it guarantees not to copy more characters than the buffer is capable of holding. In addition, the destination buffer is always null-terminated on return from this function, even if the data was truncated.

Header: atlstencil.h

Community Additions

© 2015 Microsoft