Click here to Skip to main content
16,009,407 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to extract a single character from a CString Pin
Mark Salsbery8-Mar-08 15:07
Mark Salsbery8-Mar-08 15:07 
GeneralRe: How to extract a single character from a CString Pin
Larry Mills Sr9-Mar-08 5:54
Larry Mills Sr9-Mar-08 5:54 
GeneralRe: How to extract a single character from a CString Pin
Mark Salsbery9-Mar-08 8:09
Mark Salsbery9-Mar-08 8:09 
GeneralRe: How to extract a single character from a CString Pin
Larry Mills Sr10-Mar-08 4:35
Larry Mills Sr10-Mar-08 4:35 
GeneralRe: How to extract a single character from a CString Pin
Mark Salsbery10-Mar-08 6:37
Mark Salsbery10-Mar-08 6:37 
GeneralRe: How to extract a single character from a CString Pin
Larry Mills Sr11-Mar-08 9:09
Larry Mills Sr11-Mar-08 9:09 
GeneralRe: How to extract a single character from a CString Pin
Larry Mills Sr8-Mar-08 14:07
Larry Mills Sr8-Mar-08 14:07 
GeneralRe: How to extract a single character from a CString Pin
Mark Salsbery8-Mar-08 14:30
Mark Salsbery8-Mar-08 14:30 
atoi() takes a const char * as an argument, not a TCHAR.

What are you trying to do?  Convert the TCHAR you extracted to an int?

If so, you should be using generic text mapped functions, not functions like
atoi() that only work with one character type.

Generic text mapped functions will work for Unicode or non-Unicode builds.

In a Unicode build, a TCHAR is a wchar_t
In a non-Unicode build, a TCHAR is a char

Generic-Text Mappings in Tchar.h[^]

CString is also a generic text class by the way - it's internal character type is based on the Unicode build setting.

Also, you need to pass the correct type of argument to functions.

Maybe something like this:
TCHAR chrs[2];
int ch = 0;
chrs[0] = str.GetAt(0);
chrs[1] = _T("\0");  // must be NULL terminated!
ch += _tstoi(chrs);

Mark


Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: How to extract a single character from a CString Pin
Larry Mills Sr8-Mar-08 14:45
Larry Mills Sr8-Mar-08 14:45 
GeneralRe: How to extract a single character from a CString Pin
Mark Salsbery8-Mar-08 15:05
Mark Salsbery8-Mar-08 15:05 
QuestionRe: How to extract a single character from a CString Pin
CPallini8-Mar-08 22:51
mveCPallini8-Mar-08 22:51 
GeneralHelp in De Morgans Law Pin
Ryano8-Mar-08 5:45
Ryano8-Mar-08 5:45 
GeneralProblem for Download directory FTP VC++ code Pin
chetanjoshi98-Mar-08 4:40
chetanjoshi98-Mar-08 4:40 
GeneralRe: Problem for Download directory FTP VC++ code Pin
ptr_Electron10-Mar-08 23:35
ptr_Electron10-Mar-08 23:35 
Generalplease help me. Pin
Le@rner8-Mar-08 1:19
Le@rner8-Mar-08 1:19 
GeneralRe: please help me. Pin
Cranky8-Mar-08 1:31
Cranky8-Mar-08 1:31 
GeneralRe: please help me. Pin
Mark Salsbery8-Mar-08 10:27
Mark Salsbery8-Mar-08 10:27 
GeneralRe: please help me. Pin
Hamid_RT9-Mar-08 0:49
Hamid_RT9-Mar-08 0:49 
GeneralRe: please help me. Pin
Mark Salsbery9-Mar-08 8:11
Mark Salsbery9-Mar-08 8:11 
GeneralRe: please help me. Pin
Hamid_RT9-Mar-08 19:50
Hamid_RT9-Mar-08 19:50 
Questionplease help me. Pin
liuyajuan21-Apr-08 16:18
liuyajuan21-Apr-08 16:18 
GeneralRe: please help me. Pin
Le@rner21-Apr-08 18:00
Le@rner21-Apr-08 18:00 
GeneralFailed to initialize object in a constructor Pin
cydd7-Mar-08 23:55
cydd7-Mar-08 23:55 
AnswerRe: Failed to initialize object in a constructor [modified] Pin
Rajkumar R8-Mar-08 0:00
Rajkumar R8-Mar-08 0:00 
GeneralRe: Failed to initialize object in a constructor Pin
cydd8-Mar-08 22:37
cydd8-Mar-08 22:37 

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.