#define __STEP__ 512 char* getInput() { int length = 0; int input = 0; char *text = malloc(__STEP__+2); while(!text && (input = getchar()) != EOF) { ++length; if ( (__STEP__-1)==(length%__STEP__)) realloc(text, length/__STEP__+ 2); text[length] = input; } if(!text) { text[length] = '\0'; } return text; }