Click here to Skip to main content
15,913,584 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: find the largest 1000 values Pin
shpid3r8-Nov-07 6:10
shpid3r8-Nov-07 6:10 
AnswerRe: find the largest 1000 values Pin
George_George8-Nov-07 21:08
George_George8-Nov-07 21:08 
GeneralRe: find the largest 1000 values Pin
David Crow9-Nov-07 2:47
David Crow9-Nov-07 2:47 
GeneralRe: find the largest 1000 values Pin
George_George9-Nov-07 3:14
George_George9-Nov-07 3:14 
Answerhere is my algorithm. [modified] Pin
chandu00410-Nov-07 1:02
chandu00410-Nov-07 1:02 
GeneralRe: here is my algorithm. Pin
David Crow10-Nov-07 4:05
David Crow10-Nov-07 4:05 
GeneralRe: here is my algorithm. Pin
George_George10-Nov-07 4:15
George_George10-Nov-07 4:15 
QuestionCString to TCHAR & TCHAR to CString Pin
Paulraj G6-Nov-07 20:29
Paulraj G6-Nov-07 20:29 
AnswerRe: CString to TCHAR & TCHAR to CString Pin
Cedric Moonen6-Nov-07 20:43
Cedric Moonen6-Nov-07 20:43 
GeneralRe: CString to TCHAR & TCHAR to CString Pin
Paulraj G6-Nov-07 20:59
Paulraj G6-Nov-07 20:59 
GeneralRe: CString to TCHAR & TCHAR to CString Pin
Cedric Moonen6-Nov-07 21:05
Cedric Moonen6-Nov-07 21:05 
GeneralRe: CString to TCHAR & TCHAR to CString Pin
CPallini6-Nov-07 21:14
mveCPallini6-Nov-07 21:14 
AnswerRe: CString to TCHAR; TCHAR to CString [incorrect] [modified] Pin
Llasus6-Nov-07 21:06
Llasus6-Nov-07 21:06 
GeneralHonestly Pin
CPallini6-Nov-07 21:28
mveCPallini6-Nov-07 21:28 
GeneralRe: CString to TCHAR & TCHAR to CString Pin
Cedric Moonen6-Nov-07 21:34
Cedric Moonen6-Nov-07 21:34 
Llasus wrote:
int temp = message.GetLength()*2; //multiply by 2 because of the CString format


Why multiply by 2 ? How do you know that a character is 2 bytes long ? It's only the case when UNICODE is enabled.


Llasus wrote:
tchar =(TCHAR*)malloc(temp+1); //add 1 for the NULL at the end: but doesn't work


Don't use malloc in C++. If you had used new, you won't have any problem with calculating the size. You just create an array of TCHAR and the compiler will allocate the correct size depending of UNICODE is set or not.

Llasus wrote:
memcpy(tchar, message, temp); //copy; now we have the TCHAR


Don't use memcpy to copy strings. Prefer to use the macro _tcscpy that will be strcpy if UNICODE is not declared or wscpy if UNICODE is declared (so you don't have to bother about it).

If you have garbage values at the end of your string, it's simply because you didn't put a ending zero at the end of your string.


Cédric Moonen
Software developer

Charting control [v1.2]

GeneralRe: CString to TCHAR & TCHAR to CString Pin
Raj Prathap7-Nov-07 0:09
Raj Prathap7-Nov-07 0:09 
GeneralRe: CString to TCHAR & TCHAR to CString Pin
toxcct7-Nov-07 0:30
toxcct7-Nov-07 0:30 
AnswerRe: CString to TCHAR & TCHAR to CString Pin
toxcct7-Nov-07 0:28
toxcct7-Nov-07 0:28 
QuestionWEB SERVER IN VC++ [modified] Pin
kansagous6-Nov-07 19:33
kansagous6-Nov-07 19:33 
AnswerRe: WEB SERVER IN VC++ Pin
shpid3r8-Nov-07 10:14
shpid3r8-Nov-07 10:14 
QuestionHollow Brush Pin
nitin36-Nov-07 19:24
nitin36-Nov-07 19:24 
AnswerRe: Hollow Brush Pin
Neo Andreson6-Nov-07 21:36
Neo Andreson6-Nov-07 21:36 
GeneralRe: Hollow Brush Pin
nitin36-Nov-07 22:08
nitin36-Nov-07 22:08 
GeneralRe: Hollow Brush [modified] Pin
Neo Andreson6-Nov-07 22:28
Neo Andreson6-Nov-07 22:28 
AnswerRe: Hollow Brush Pin
Mark Salsbery7-Nov-07 7:54
Mark Salsbery7-Nov-07 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.