How can I parse integers passed to an application as command line arguments if the app is unicode?
Unicode apps have a main like this:
int _tmain(int argc, _TCHAR* argv[])
argv[?] is a wchar_t*. That means i can’t use atoi. How can I convert it to an integer? Is stringstream the best option?
if you have a TCHAR array or a pointer to the begin of it, you can use
std::basic_istringstreamto work with it:Now,
numberis the converted number. This will work in ANSI mode (_TCHAR is typedef’ed tochar) and in Unicode (_TCHAR is typedef`ed to wchar_t as you say) mode.