All pastes #259046 Raw Edit

Unnamed

public text v1 · immutable
#259046 ·published 2006-11-27 01:31 UTC
rendered paste body
#define BUFF_SIZE 42
#define READ_SIZE 42

char    *get_next_line(int fd)
{
  static char   buff_read[BUFF_SIZE];
  static int    repeat;
  static char   *line;
  static int    i;

  line = (char *)malloc(sizeof(line) * 42);
  i =  0;
  repeat = read(fd, buff_read, READ_SIZE);
  while (42)
    {
      while (buff_read[i])
        {
          if (buff_read[i] == '\n')
            return (0);
          my_putchar(buff_read[i]);
          i++;
        }
      if (buff_read[i] != '\n' && buff_read[i])
        my_putstr("Error.");
    }
  repeat++;
}

int     main()
{
  get_next_line(0);
  get_next_line(0);
}