在C近拍实现putc将()的 [英] Macro implementation of putc() in C

查看:114
本文介绍了在C近拍实现putc将()的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找的宏实现putc将(c)中的功能。

I was looking for the macro implementation of putc() function in C.

一个实现我在C编程语言发现由Ritchie和Kernighan的

One implementation which i found in "The C programming language" by Ritchie and Kernighan

#define putc(x,p) (--(p)->cnt >=0 \
                  ?(unsigned char) *(p)->ptr++ :_flushbuf((x),p))

文件结构的定义如下:

The file structure definition is as follows

typedef struct _iobuf {
                int cnt;
                char *ptr;
                char *base;
                int flag;
                int fd;
             }FILE;

我看不到CNT被初始化如何当我们调用putc将?

I am unable to see how cnt gets initialised when we call putc ?

推荐答案

它无疑是的fopen 初始化,并由其他任何读取/文件写入修改。

It's undoubtedly initialized by fopen, and modified by anything else that reads/writes the file.

这篇关于在C近拍实现putc将()的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆