修改并测试下面中的函数,使得可以在n个字符后,或第一个空格、制表符、换行符后停止读取输入,由上述情况中最先被满足的那个终止读取(不能用scanf()函数)。
#include <stdio.h> void input(char *p, int n); int main(void) { char a[81]; int n; puts("input the char number of your string:"); scanf("%d",&n); getchar(); //滤去回车 puts("input your string:"); input(a,n); puts(a); return 0; } void input(char *p, int n) { int i; for (i=0;i<n;i++) *(p+i) = getchar(); *(p+i) = '\0'; }