fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. int main()
  5. {
  6. char* buf = new char[8];
  7. strcpy(buf, "Hello ");
  8.  
  9. std::cout << buf << "!\n";
  10.  
  11. char* end = buf + strlen(buf) - 1;
  12. while(end > buf && isspace(*end))
  13. --end;
  14. *(end+1) = 0;
  15.  
  16. std::cout << buf << "!\n";
  17. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
Hello  !
Hello!