fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void foo(const char* path) {
  5. char* p = const_cast<char*>(path);
  6. char tmp = p[1];
  7. p[1] = '\0';
  8. std::cout << p << std::endl;
  9. p[1] = tmp;
  10. }
  11.  
  12. int main() {
  13. char obichniy[111];
  14. std::cin >> obichniy;
  15. foo(obichniy);
  16.  
  17. const char* pethu = "pethu";
  18. foo(pethu);
  19.  
  20. return 0;
  21. }
Runtime error #stdin #stdout 0.01s 5540KB
stdin
pethu2
stdout
p