char* resize(const char* str, unsigned int size, unsigned int new_size)
{
char* ptr = new char[new_size];
int min_size = new_size > size ? size : new_size;
for (int i = 0; i < min_size; i++)
{
ptr[i] = str[i];
}
delete[] str;
return ptr;
}
char* getline()
{
char* line = new char[1];
char simbol;
unsigned int size = 1;
while (cin.get(simbol) && simbol != '\n' && simbol != '\0')
{
line = resize(line, size, size + 1);
line[size-1] = simbol;
size++;
}
return line;
}
int main()
{
char* line = getline();
for (int i = 0; line[i] != '\0'; i++)
{
cout << line[i];
}
cout << endl;
return 0;
}