This site is no longer active and is available for archival purposes only. Registration and login is disabled.

What am I doing wrong


What am I doing wrong

Postby Dranith » Aug 5, 2003 @ 12:27am

Dranith
 


What am I doing wrong

Postby Kzinti » Aug 5, 2003 @ 12:40am

Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


Postby Dranith » Aug 5, 2003 @ 12:42am

Dranith
 


Postby Dranith » Aug 5, 2003 @ 2:20am

Dranith
 


Postby Kzinti » Aug 5, 2003 @ 6:53am

Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


What I'm doing

Postby mlepage » Aug 6, 2003 @ 4:36am

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.
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Postby Pejo Software - Per » Aug 6, 2003 @ 9:01am

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.
User avatar
Pejo Software - Per
pm Insider
 
Posts: 343
Joined: Apr 25, 2002 @ 1:00pm
Location: Mölndal, Sweden


True

Postby mlepage » Aug 6, 2003 @ 6:49pm

User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Postby Dranith » Aug 8, 2003 @ 12:00am

Dranith
 


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum