Exemplo n.º 1
0
main(){
    int c, pos, i, j ,m;

    pos = 0;
    i = 0;
    j = 0;
    m = 0;

    while ((c = getchar()) != EOF ){
        if (c == ' ' || c == '\t' || c == '\n'){
            for( j = 0; j < i ; j++ )
                putchar(word[j]);
            if (m == 1)
                pos = i + 1;

            i = 0;
            m = 0;

            if (c == '\t')
                pos = exptab(pos);
            if (c == ' '){
                ++pos;
                if (pos > MAXCOL){
                    putchar('\n');
                    pos = 1;
                }
                putchar(' ');
            }
            if (c == '\n'){
                putchar('\n');
                pos = 0;
            }
        } else {
            word[i] = c;
            ++pos;
            ++i;
            if ( pos >= MAXCOL && i < MAXCOL ){
                putchar('\n');
                pos = 0;
                m = 1;
            }
        }
    }
    for( j = 0; j < i ; j++ )
        putchar(word[j]);
}
Exemplo n.º 2
0
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);
        }
    }
}