#include<stdio.h>
#define TABINC 5 /*tab increment size*/
//replace tabs with the proper number of blanks
int main(void)
{
int nb, pos, c;
nb = 0; //number of blanks nessary
pos = 1; //position of character in line
while ((c = getchar()) != EOF)
{
if (c == '\t')
{
nb = TABINC - (pos - 1) % TABINC;
while (nb > 0)
{
putchar(' ');
pos++;
nb--;
}
}
else if (c == '\n')
{
putchar(c);
pos = 1;
}
else
{
putchar(c);
pos++;
}
}
return 0;
#define TABINC 5 /*tab increment size*/
//replace tabs with the proper number of blanks
int main(void)
{
int nb, pos, c;
nb = 0; //number of blanks nessary
pos = 1; //position of character in line
while ((c = getchar()) != EOF)
{
if (c == '\t')
{
nb = TABINC - (pos - 1) % TABINC;
while (nb > 0)
{
putchar(' ');
pos++;
nb--;
}
}
else if (c == '\n')
{
putchar(c);
pos = 1;
}
else
{
putchar(c);
pos++;
}
}
return 0;
}
运算结果前两次成功去掉【tab】,但之后替换运行失败,可能是系统原因