Warning is due to the narrowing of an INT
object to a TCHAR
one. Theses types exist to afford certainly fixability and may be the like range with other compilations settings.
TCHAR iChar = (TCHAR) toupper(sPassword[4]);
as answered by @Zsigmond Szabó is a good idea - when TCHAR
is a char
or friends.
Yet there lies a deeper issue: toupper()
is for single byte case conversion and is not the best conversion function to use when TCHAR
is not char
or the like.
Code might have as well been:
int iChar = toupper(sPassword[4]); // if toupper must be used
sPassword[4] = (TCHAR) iChar;
To handle generally TCHAR
case conversion, code needs more flexibility.
TCHAR
is not a standard C type nor definition.
Assuming this is a MS TCHAR
, consider _totupper()
.
TCHAR iChar = (TCHAR) _totupper(sPassword[4]);
sPassword[4] = iChar;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…