All pastes #274917 Raw Edit

David R.S. Robinson

public text v1 · immutable
·published 2006-12-11 02:10 UTC
rendered paste body
void gets (char *s, unsigned int len){  unsigned int index = 0;  char in;  while (index < len)  {    in = getc ();    if (in == '\b')    {      if (index)      {        puts("\b \b");        index--;      }      continue;    }    else if (in == '\r')    {      putc ('\n');      break;    }    putc (in);    s[index++] = in;  }  s[index] = '\0';  /* Emulate that the person went to the next line, if we run out of space. */  if (index == len)    putc ('\n');}