fgetc getc getchar fputc putc putchar

                                                 fgetc getc getchar

                                                 fputc putc putchar

 

fgetc 

调用方式:

int fgetc( FILE *stream )

功能

Read a character(字符当作unsigned char类型来读取,然后转换为int类型) from a stream

返回值

Fgetc return the character read as an int or return EOF to indicate an error or end of file. Use feof or ferror to distinguish between an error and an end-of-file condition. If a read error occurs, the error indicator for the stream is set.    

实现方式

Implemented only as a function

 

getc

调用方式   

int getc( FILE *stream );          

功能

Same as fgetc, but implemented as a function and as a macro

返回值

Return the character read. To indicate an read error or end-of-file condition, getc return EOF.Use ferror or feof to check for an error or for end of file.

实现方式

Implemented as a function and as a macro.调用时,默认使用宏实现。

宏实现:#define getc(_stream)     (--(_stream)->_cnt >= 0 /

                ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))

 

getchar   

调用方式 

int getchar( void )

功能

从标准输入stdin读入一个字符。程序等待你输入的时候,你可以输入多个字符,回车后程序继续执行,但getchar只读入一个字符。

返回值

Return the character read. To indicate an read error or end-of-file condition, getchar returns EOF. Use ferror or feof to check for an error or for end of file.

实现方式              

Implemented as a function and as a macro. 调用时,默认使用宏实现。

宏实现:#define getchar()         getc(stdin)

 

 

fgetcgetc的功能是一样的,但他们还是有区别的

The difference between the first two functions is that getc can be implemented as a macro, whereas fgetc cannot be implemented as a macro. This means three things.

1.The argument to getc should not be an expression with side effects.  因而用宏一般不使用有“副作用”的表达式。

2.Since fgetc is guaranteed to be a function, we can take its address. This allows us to pass the address of fgetc as an argument to another function.

3.Calls to fgetc probably take longer than calls to getc, as it usually takes more time to call a function.

 

 

fputc

调用方式

int fputc( int c, FILE *stream )

功能

Write a character to a stream。在将c写入流之前,会强制将c转换为unsigned char

实现方式

Implemented only as a function

返回值

Return the character written. A return value of EOF indicates an error.

 

putc

调用方式

int fputc( int c, FILE *stream )

功能

fput的一样

实现方式

Implemented as a function and a macro.调用时,默认使用宏实现。

宏实现:#define putc(_c,_stream)  (--(_stream)->_cnt >= 0 /

                ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) :  _flsbuf((_c),(_stream)))

返回值

Return the character written. A return value of EOF indicates an error.

 

putchar

调用方式

int putchar( int c )

功能

Write a characte to stdout.

实现方式

Implemented as a function and a macro  调用时,默认使用宏实现

       宏实现:#define putchar()         putchar(stdout)

返回值

Return the character written. A return value of EOF indicates an error.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值