All pastes #769779 Raw Edit

Anonymous

public c v1 · immutable
·published 2007-11-11 17:43 UTC
rendered paste body
char* 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;}