将多个空格转化为只有一个空格输出

#include <stdio.h>

int main()
{
    char c = 0;
    int num = 0;
    while ((c = getchar()) != EOF) {
        if (c == 32) {
            ++num;
        }
        else {
            num = 0;
        }
        if (num <= 1) {
            putchar(c);
        }
    }
}

空格这一字符的ASCII码为32.