C Tutorial/Wide Character String/Wide Char Calculation

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Converting uppercase to lowercase for wide characters

#include <stdio.h>
int main(void)
{
  wchar_t letter = 0;
  printf("Enter an uppercase letter:"); 
  scanf("%lc", &letter);                
  if(letter >= L"A")
    if (letter <= L"Z")
    {                  
      letter = letter - L"A"+ L"a";
      printf("You entered an uppercase %lc\n", letter);
    }
    else                           
      printf("Try using the shift key, Bud! I want a capital letter.\n");
  return 0;
}
Enter an uppercase letter:A
     You entered an uppercase a