Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

towlower() return "?" instead of this character in lower register

it is simple version just for ask, i have this program

wchar_t c;
wprintf(L"input\n");
wscanf(L"%d", &c);
wprintf(L"output\n");
wprintf(L"%lc", towlower(c));

and this input/output
enter image description here

if i input "W" there output "?", with another characters i have the same situation.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

in the line wscanf(L"%d", &c);, you passed %d as format specifier. So wscanf() is searching for an integer, but you are passing a character instead. Changing to %c will solve it.

See the specification in the wscanf(3) manpage:

   d       Matches an optionally signed decimal integer, whose format is the same
           as expected for the subject sequence of wcstol() with the value 10 for
           the  base argument. In the absence of a size modifier, the application
           shall ensure that the corresponding argument is a pointer to int.

           ...

   c       Matches  a sequence of wide characters of exactly the number specified
           by the field width (1 if no field width is present in  the  conversion
           specification).
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading