字符(串)输入输出函数
- 输出函数
#include <stdio.h>
int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
int putc(int c, FILE *stream);
int putchar(int c);
int puts(const char *s);
注:fputs() writes the string s to stream, without its terminating null byte (' ').可以连续向流写字符串而一次读出。
puts() writes the string s and a trailing newline to stdout.返回值个数包含‘ ’。
RETURN VALUE
fputc(), putc() and putchar() return the character written as an unsigned char cast to an int or EOF on error.
puts() and fputs() return a nonnegative number(个数) on success, or EOF on error.
- 输入函数
#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);
int ungetc(int c, FILE *stream);
gets() reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces with a null byte (' '). No check for buffer overrun is performed
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte (' ') is stored after the last character in the buffer.
fgets()在缓冲区最后加字符串结束符‘