C语言替换特定字符

这个问题的思路应该从字符从字符的角度展开,不能一蹴而就。

 

int execise3()
{
    int c; // the character currently input
    while((c = getchar()) != '0')
    {
        if(c == '/t')
        {
            putchar('//');
            putchar('t');
        }
        else if(c == '/b')
        {   
            putchar('//');
            putchar('b');
        }
        else if(c == '//')
        {
            putchar('//');
            putchar('//');
        }
        else
            putchar(c);
    }
}

int main()
{
    execise3();
    return 0;
}

你可能感兴趣的:(c,input,语言,character)