Anonymous
public c v1 · immutablechar* getInput(){ int length = 0; int input = 0; char *text = malloc(_STEP_ + 1), *temp; if (NULL == text) { return NULL; } while((input = getchar()) != EOF) { if ( (_STEP_ - 1) == (length % _STEP_) ) { if (NULL == (temp=realloc(text, ( (length + 1) + _STEP_ + 1)))) { free(text); return NULL; } text=temp; } text[length] = (char)input; length++; } text[length] = '\0'; return text;}