fork download
  1. #include <cstdio> // for printf, sprintf.
  2. #include <cstdlib> // for EXIT_FAILURE
  3. #include <tchar.h> // for _T.
  4. #include <Windows.h> // for MessageBox.
  5. #include <vector> // for vector.
  6.  
  7. /*
  8.  
  9. 実行方法:
  10. cmd /u /c "dir /b" > "unique.txt"
  11. test.exe < "unique.txt"
  12.  
  13. */
  14.  
  15. int main()
  16. {
  17. std::vector<char> kuso;
  18.  
  19. int ch;
  20. while ( ch = std::fgetc(stdin), ch != EOF )
  21. {
  22. kuso.push_back(ch);
  23. }
  24.  
  25. if ( (kuso.size() % 2) != 0 )
  26. {
  27. _tprintf(_T("Oops...\n"));
  28. return EXIT_FAILURE;
  29. }
  30.  
  31. TCHAR msg[100];
  32. _stprintf(msg, _T("%02X %02X %02X %02X"), kuso[0], kuso[1], kuso[2], kuso[3]);
  33. ::MessageBox(nullptr, msg, nullptr, 0); // 21 9D ....
  34.  
  35. std::vector<wchar_t> buri;
  36. auto kuso_size = kuso.size();
  37. for ( auto i = 0; i < kuso_size; i += 2 )
  38. {
  39. auto wch = ((kuso[i + 1] & 0xFF) << 8) | (kuso[i] & 0xFF);
  40. buri.push_back(static_cast<wchar_t>(wch));
  41. }
  42. buri.push_back(wchar_t()); // NUL terminated.
  43.  
  44. _stprintf(msg, _T("%04X %04X %04X %04X"), buri[0], buri[1], buri[2], buri[3]);
  45. ::MessageBox(nullptr, msg, nullptr, 0); // 219D ....
  46.  
  47. ::MessageBoxW(nullptr, buri.data(), L"unkoo", 0);
  48. }
  49.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:30: fatal error: tchar.h: No such file or directory
compilation terminated.
stdout
Standard output is empty