UNICODE and Command Line processing - Windows CE
This is a discussion on UNICODE and Command Line processing - Windows CE ; Hi,
I cant get to grips with this unicode characters. I don't know what
types I should be converted and what should be used to convert them.
I am trying to process a command line in the format:-
serial -1 ...
-
UNICODE and Command Line processing
Hi,
I cant get to grips with this unicode characters. I don't know what
types I should be converted and what should be used to convert them.
I am trying to process a command line in the format:-
serial -1 -9600
The code that I have is below, needless to say it does not work!!
What is wrong with this and how should this be done?
TCHAR *pDash = _tcschr (lpCmdLine, _T( '-' ));
TCHAR t_string[256];
TCHAR t_string1[256];
int com_num = 0;
int baud_rate = 0;
com_num = _ttoi ((TCHAR *)(*(pDash + 1)));
_stprintf(t_string,_T("COM%d:"), com_num);
_tprintf (L"<%s>\n", t_string);
pDash = _tcschr (pDash, _T( '-' ));
baud_rate = _ttoi ((TCHAR *)(*(pDash + 1)));
_stprintf(t_string1,_T("COM%d:"), baud_rate);
_tprintf (L"<%s>\n", t_string1);
Thanks,
J
-
Re: UNICODE and Command Line processing
_ttoi takes a pointer to a NULL-terminated string, not a character. You're
passing a character when you do *(pDash+1) - and typecasting it as a TCHAR *
won't help make it one.
You just want this: _ttoi(pDash+1);
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"John Flynn" wrote in message
news:761ef898.0401300057.5d843f25@posting.google.c om...
> Hi,
>
> I cant get to grips with this unicode characters. I don't know what
> types I should be converted and what should be used to convert them.
>
> I am trying to process a command line in the format:-
>
> serial -1 -9600
>
> The code that I have is below, needless to say it does not work!!
> What is wrong with this and how should this be done?
>
> TCHAR *pDash = _tcschr (lpCmdLine, _T( '-' ));
> TCHAR t_string[256];
> TCHAR t_string1[256];
>
> int com_num = 0;
> int baud_rate = 0;
>
> com_num = _ttoi ((TCHAR *)(*(pDash + 1)));
> _stprintf(t_string,_T("COM%d:"), com_num);
> _tprintf (L"<%s>\n", t_string);
>
> pDash = _tcschr (pDash, _T( '-' ));
> baud_rate = _ttoi ((TCHAR *)(*(pDash + 1)));
> _stprintf(t_string1,_T("COM%d:"), baud_rate);
> _tprintf (L"<%s>\n", t_string1);
>
> Thanks,
> J