All pastes #769582 Raw Edit

Something

public text v1 · immutable
·published 2007-11-11 15:34 UTC
rendered paste body
[kakazza@pluto ~]$ gcc -Wall -o ass_04 ass_04.c
ass_04.c: In function âgetInputâ:
ass_04.c:34: warning: ignoring return value of âreallocâ, declared with attribute warn_unused_result
ass_04.c: In function âprimefactorsâ:
ass_04.c:58: error: âfactor_01â undeclared (first use in this function)
ass_04.c:58: error: (Each undeclared identifier is reported only once
ass_04.c:58: error: for each function it appears in.)


#define _STEP_ 64

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