/*
实现readline,如果要指定文件,就用fgets()实现,如果从串口读,用哪个都行了。
char * readline (const char *prompt);
#include <stdio.h>
int fgetc(FILE *stream);
char *fgets(char *s, int size, FILE *stream);
int getc(FILE *stream);
int getchar(void);
char *gets(char *s)
fgets() reads inat most one less than size charactersfrom stream and stores them intothe buffer pointed toby s. Reading stops after an EOF or a newline. If a newline isread, itis stored intothe buffer. A terminating null byte ('\0') is stored afterthelastcharacterinthe buffer.
fgets() return s on success, and NULL onerroror when endoffile occurs
while no characters have been read.
fgetc() reads the next characterfrom stream and returns itas an unsigned char cast to
an int, or EOF onendoffileorerror.
getc() is equivalent to fgetc() except thatit may be implemented as a macro which evalu‐
ates stream more than once.
getchar() is equivalent to getc(stdin).
gets() reads a line from stdin intothe buffer pointed toby s until either a terminating
newline or EOF, which it replaces with a null byte ('\0'). No check for buffer overrun
is performed (see BUGS below).
gets() return s on success, and NULL onerroror when endoffile occurs
while no characters have been read.
Never use gets(). Because itis impossible totellwithout knowing the data in advance
how many characters gets() will read, and because gets() will continueto store charac‐
ters past theendofthe buffer, itis extremely dangerous to use. It has been used to
break computer security. Use fgets() instead.
======
ferror系列、fdopen、sscanf/sprintf系列。
*/