fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. char *resize(const char *str, unsigned size, unsigned new_size)
  6. {
  7. char * str_two = new char[new_size];
  8. for(int i = 0; i < size && i < new_size; ++i) {
  9. str_two[i] = str[i];}
  10. delete [] str;
  11. return str_two;
  12. }
  13.  
  14.  
  15. char *getline()
  16. {
  17. char ch = 0;
  18. int count = 1;
  19. int index = 0;
  20. char * m = new char[1];
  21. while (cin.get(ch), ch != '\n'){
  22. m[index] = ch;
  23. index++;
  24. count++;
  25. m = resize(m, count, count + 1);
  26. }
  27. m[count] = '\0';
  28. return m;
  29. }
  30.  
  31.  
  32. int main()
  33. {
  34. char * m = getline();
  35. int i = 0;
  36. while (m[i] != '\0' && ++i) cout << m[i];
  37. }
Success #stdin #stdout 0s 4376KB
stdin
K i r i l l Romaniuk
stdout
 i r i l l Romaniuk