字符串+文件处理函数

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C语言标准输入输出:待续

printf 格式输出到屏幕//把指定内存空间中内容格式输出到屏幕;

fprintf 格式输出到磁盘//

scanf 从屏幕格式输入//从stdin中格式读入到给定变量空间中

fscanf 从磁盘格式输入

putchar 字符输出到屏幕

puts 字符串输出到屏幕

fputc 字符输出到磁盘

fputs 字符串输出到磁盘

getchar 从屏幕得到一个字符//从stdin中读取一个字符,返回字符ASCII值gets 从屏幕得到一个字符串//从stdin中读取字符串,返回内存空间位置fgetc 从磁盘得到一个字符

fgets 从磁盘得到一个字符串

fputc, fputs, putc, putchar, puts - output of characters and strings

SYNOPSIS

#include

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);

DESCRIPTION

fputc() writes the character c, cast to an unsigned char, to stream.

fputs() writes the string s to stream, without its terminating null byte ('\0').

putc() is equivalent to fputc() except that it may be implemented as a macro which evaluates stream more than once.

putchar(c); is equivalent to putc(c, stdout).

puts() writes the string s and a trailing newline to stdout.

RETURN V ALUE

fputc(), putc() and putchar() return the character written as an unsigned char cast to an int or EOFon error.

puts() and fputs() return a nonnegative number on success, or EOF on error.

fgetc, fgets, getc, getchar, gets, ungetc - input of characters and strings

SYNOPSIS

#include

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);

DESCRIPTION

fgetc() reads the next character from stream and returns it as an unsigned char cast to an int, or EOF

on end of file or error.

getc() is equivalent to fgetc() except that it may be implemented as a macro which evaluates stream

more than once.

getchar() is equivalent to getc(stdin).

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 ('\0'). No check for buffer overrun is performed (see BUGS

below).

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 ('\0') is stored after the last character in the buffer.

ungetc() pushes c back to stream, cast to(铸造) unsigned char, where it is available for subsequent read operations. Pushed-back characters will be returned in reverse order; only one pushback is guaran‐teed. Calls to the functions described here can be mixed with each other and with calls to other input func‐tions from the stdio library for the same input stream.

For nonlocking counterparts, see unlocked_stdio(3).

RETURN V ALUE

fgetc(), getc() and getchar() return the character read as an unsigned char cast to an int or EOF on

end of file or error.

gets() and fgets() return s on success, and NULL on error or when end of file occurs while no charac‐

ters have been read.

相关文档
最新文档