Page 1 of 1

What am I doing wrong

PostPosted: Aug 5, 2003 @ 12:27am
by Dranith

What am I doing wrong

PostPosted: Aug 5, 2003 @ 12:40am
by Kzinti

PostPosted: Aug 5, 2003 @ 12:42am
by Dranith

PostPosted: Aug 5, 2003 @ 2:20am
by Dranith

PostPosted: Aug 5, 2003 @ 6:53am
by Kzinti

What I'm doing

PostPosted: Aug 6, 2003 @ 4:36am
by mlepage
I installed STLport. You can use std::string OK, just not streams.

I use the <tchar.h> routines for text. That means using _sntprintf, _tcscpy, _tfscanf, and all those wonderfully named functions.

Just be smart about it. Write a small class that encapsulates your buffer of _TCHAR and the size of that buffer. (Hint: you can use std::vector because it is array compatible, see Meyer's Effective STL book.) Make that array one more than you need, and pre-terminate it with a null character in that last position. Then always use functions that take a size: snprintf instead of sprintf, "%32s" instead of "%s" in sscanf, strncpy instead of strcpy, etc.

If you really care about performance, you can make a templated version of that class with the size as a template parameter.

This approach is better than hardcoding _TCHAR mybuffer[128] and sprintf(mybuffer, 128, src) all through your code.

PostPosted: Aug 6, 2003 @ 9:01am
by Pejo Software - Per
Just a little note in case anyone missed it:
std::string actually is defined as basic_string<char> ans wstring is defined as basic_string<wchar_t> so you can use basic_string<TCHAR> if you would like to work with TCHARs.

True

PostPosted: Aug 6, 2003 @ 6:49pm
by mlepage

PostPosted: Aug 8, 2003 @ 12:00am
by Dranith