getchar 和 putchar 的使用
编写一个输入输出字符程序,要求使用getchar和putchar 函数,输入的字符若遇连续的空格只能输出一个。
它就只是 输入或输出 一个字符!!!
我也是新手!!
#include <conio.h> void main(void) { const wint_t space_character(L' '); const wint_t null_character(L'\0'); const wint_t end_character(0x000D); wint_t character; wint_t last_character(null_character); do { character = _getwch(); if (character == space_character) { if (character != last_character) { last_character = character; } else { continue; } } else { if (last_character == space_character) { last_character = null_character; } } _putwch(character); } while (character != end_character); }