fork download
  1. #include <cstdio>
  2. #include <string>
  3.  
  4. int main(void) {
  5. // the ascii code of 'z' is 122
  6. // char can contain -128 ~ 127
  7. char c = 'z';
  8. c += 6;
  9. printf("c == %d\n", (int)c);
  10.  
  11. std::string s = "z";
  12. s[0] += 6;
  13. printf("s[0] == %d\n", (int)s[0]);
  14. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
c    == -128
s[0] == -128