char_test.hpp 625 B

123456789101112131415161718192021222324252627282930
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. int test_char()
  6. {
  7. using namespace std;
  8. string c1, c2;
  9. // cin >> c1;
  10. c1 = "very good";
  11. const int leng = c1.length();
  12. int enc_letter[leng];
  13. fill(enc_letter, enc_letter + leng, 10);
  14. // memset(enc_letter, 0, sizeof(int)*leng);
  15. for (int i = 0; i < c1.length(); i++)
  16. {
  17. //cout << int(c1[i]) << ' ';
  18. enc_letter[i] = int(c1[i]);
  19. cout << enc_letter[i] << ' ';
  20. }
  21. for (int i = 0; i < c1.length(); i++)
  22. {
  23. cout << char(enc_letter[i]);
  24. }
  25. cout << endl;
  26. return 0;
  27. }