/* copies s into d till the last whitespace is reached returning number of characters copied. */ int fold(char s[], char d[]){ int length = 0; while(s[length] != '\0'){ ++length; } int i; for (i = 0; i < LINE_LENGTH; ++i){ d[i] = s[i]; } if(s[i] != '\0'){ d[findblnk(d, i, -i)] = '\n'; } return i; }
int main(){ int c, pos; pos = 0; while( (c = getchar()) != EOF){ line[pos] = c; if( c == '\t') pos = exptab(pos); else if( c == '\n'){ printl(pos); pos = 0; } else if(++pos >= MAXCOL){ pos = findblnk(pos); printl(pos); pos = newpos(pos); } } }