David R.S. Robinson
public text v1 · immutablevoid 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');}