標準 IO 輸出函數

PUTS(3)                                       Linux Programmer's Manual                                       PUTS(3)

NAME
       fputc, fputs, putc, putchar, puts - output of characters and strings		/*字符和字符串輸出*/

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

DESCRIPTION
       fputc() writes the character c, cast to an unsigned char, to stream.
	   /*fputc 將一個無符號字符(參數 c)寫入流中*/

       fputs() writes the string s to stream, without its terminating null byte ('\0').
	   /*fputs 將一個字符串 s 輸出到流中(不包括字符串的結束符'\0')*/

       putc()  is equivalent to fputc() except that it may be implemented as a macro which evaluates stream more than once.
	   /*putc 等同於 fputc,但 putc 是作爲一個宏來執行的,因此在操作時 putc 的參數不應當是具有副作用的表達式,否則可能會被計算多次*/

       putchar(c) is equivalent to putc(c, stdout).
	   /*putchar(c) = putc(c, stdout)*/

       puts() writes the string s and a trailing newline to stdout.
	   /*puts 將字符串以及末尾換行符('\n')寫入標準輸出*/

       Calls to the functions described here can be mixed with each other and with calls to  other  output  functions from the stdio library for the same output stream.
	   /*對於相同的輸出流,這裏調用的函數以及標準庫中的其他輸出函數都可以相互之間混合使用*/

       For nonlocking counterparts, see unlocked_stdio(3).
	   /*對於非鎖定的輸出函數,請參閱 unlocked_stdio(3)*/

RETURN VALUE
       fputc(), putc() and putchar() return the character written as an unsigned char cast to an int or EOF on error.
	   /*fputc、putc 和 putchar 會將輸出的字符轉換成無符號類型字符後再以 int 類型作爲返回值,如果出錯時返回 EOF*/

       puts() and fputs() return a nonnegative number on success, or EOF on error.
	   /*puts 和 fputs 成功返回非負數,錯誤返回 EOF*/

ATTRIBUTES
       For an explanation of the terms used in this section, see attributes(7).

       ┌──────────────────────────┬───────────────┬─────────┐
       │Interface                 │ Attribute     │ Value   │
       ├──────────────────────────┼───────────────┼─────────┤
       │fputc(), fputs(), putc(), │ Thread safety │ MT-Safe │
       │putchar(), puts()         │               │         │
       └──────────────────────────┴───────────────┴─────────┘
CONFORMING TO
       POSIX.1-2001, POSIX.1-2008, C89, C99.

BUGS
       It is not advisable to mix calls to output functions from the stdio library with low-level calls  to  write(2) for  the file descriptor associated with the same output stream; the results will be undefined and very probably not what you want.
	   /*對於和輸出流相關的文件描述符,不建議將標準庫的輸出函數與低級(這裏的低級指的是更接近硬件底層的函數,一般爲系統調用)的 write 混合使用,如果這樣做可能會產生一些未知的問題,並且結果非常有可能並不是你想要的*/

SEE ALSO
       write(2), ferror(3), fgets(3), fopen(3), fputwc(3), fputws(3),  fseek(3),  fwrite(3),  putwchar(3),  scanf(3), unlocked_stdio(3)

COLOPHON
       This  page  is part of release 4.04 of the Linux man-pages project.  A description of the project, information about   reporting   bugs,   and    the    latest    version    of    this    page,    can    be    found    at http://www.kernel.org/doc/man-pages/.

GNU                                                   2015-08-08                                              PUTS(3)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章