利用getchar()构建fgets()函数
#include <stdio.h> #define SIZE 80 char * f_get(char arr[], int n); int main(void) { char input[SIZE]; f_get(input,SIZE); printf("%s\n",input); return 0; } char * f_get(char arr[], int n) { char *p; int i = 0; p = arr; *p = getchar(); while (*p != '\n') { *++p = getchar(); } *++p = '\0'; }