Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char *resize(const char *str, unsigned size, unsigned new_size)
- {
- char *str1=new char[new_size];
- for (int i=0; i<size; i++)
- {
- *(str1+i)=*(str+i);
- }
- delete []str;
- return str1;
- }
- char *getline()
- {
- char t;
- int size=1;
- char *str2=new char[size];
- int i=0;
- while ((cin.get(t))&&(t!='\n'))
- {
- i++;
- size+=1;
- str2=resize(str2, size-1,size );
- *(str2+i)=t;
- }
- resize(str2, size,size +1);
- *(str2+size)='\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement