SHARE
TWEET

polskie_znaki_cpp

pabloducato Dec 18th, 2017 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. char *tr(char *str)
  8. {
  9.     static char buff[256];
  10.     char cp[] = "\245\206\251\210\344\242\230\276\253\244\217\250\235\343\340\227\275\215ąćęłńóśżźĄĆĘŁŃÓŚŻŹ";
  11.     if (strlen(str) >= sizeof(buff)) return str;
  12.     char *bf = buff;
  13.     while (*str)
  14.     {
  15.         char *pos = strchr(cp + 18, *str);
  16.         *(bf++) = pos ? *(pos - 18) : *str;
  17.         ++str;
  18.     }
  19.     *bf = 0;
  20.     return buff;
  21. }
  22.  
  23. string napis;
  24.  
  25. int main()
  26. {
  27.  
  28.     cout << tr("Zażółć gęślą jaźń") << endl;
  29.  
  30.     cin>>napis;
  31.     cout<<tr("Wpisany ciąg znaków: ")<<napis;
  32.  
  33.     return 0;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top