Advertisement
Guest User

аняя

a guest
Oct 4th, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. char *resize(const char *str, unsigned size, unsigned new_size)
  4. {
  5. char *str1=new char[new_size];
  6. for (int i=0; i<size; i++)
  7. {
  8.  
  9. *(str1+i)=*(str+i);
  10. }
  11. delete []str;
  12.  
  13. return str1;
  14.  
  15. }
  16.  
  17. char *getline()
  18. {
  19. char t;
  20.  
  21. int size=1;
  22. char *str2=new char[size];
  23. int i=0;
  24. while ((cin.get(t))&&(t!='\n'))
  25. {
  26.  
  27. i++;
  28. size+=1;
  29. str2=resize(str2, size-1,size );
  30. *(str2+i)=t;
  31.  
  32. }
  33. resize(str2, size,size +1);
  34.  
  35. *(str2+size)='\0';
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement