文档章节

关于EOF

zray4u
 zray4u
发布于 2016/11/16 20:29
字数 474
阅读 3
收藏 0

相关文章

EOF是什么? - 阮一峰的网络日志
http://www.ruanyifeng.com/blog/2011/11/eof.html


constant
<cstdio>
EOF
End-of-File
It is a macro definition of type int that expands into(扩展成) a negative integral constant expression (generally, -1).
It is used as the value returned by several functions in header <cstdio> to indicate that the End-of-File has been reached or to signal some other failure conditions.
It is also used as the value to represent an invalid character.
In C++, this macro corresponds to the value of char_traits<char>::eof().


class template

<string>

std::char_traits

template <class charT> struct char_traits;
template <> struct char_traits<char>;
template <> struct char_traits<wchar_t>;

Character traits

Character traits classes specify character properties and provide specific semantics for certain operations on characters and sequences of characters.

The standard library includes a standard set of character traits classes that can be instantiated from the char_traitstemplate, and which are used by default both for the basic_string objects and for the input/output stream objects. But any other class that follows the requirements of a character traits class can be used instead. This reference attempts to describe both the definition of the standard char_traits and the requirements for custom character traits classes.

 

Template parameters

charT

Character type.
The class defines the standard character traits for this character type.
This shall be one of the types for which an specialization is provided.
Aliased as member type char_traits::char_type.

 

Template specializations

The char_traits standard template supports to be instantiated with at least the following character types:

type Description
char Basic character set (size of 1 byte)
wchar_t Wide character set (same size, signedness, and alignment as another integral type)

 

Member types

member type description for character traits types definition
char wchar_t
char_type The template parameter (charT) char wchar_t
int_type Integral type that can represent all charT values, as well as eof() int wint_t
off_type A type that behaves like streamoff streamoff streamoff
pos_type A type that behaves like streampos streampos wstreampos
state_type Multibyte transformation state type, such as mbstate_t mbstate_t mbstate_t

 

Member functions

eq

Compare characters for equality ( public static member function )

lt

Compare characters for inequality ( public static member function )

length

Get length of null-terminated string ( public static member function )

assign

Assign character ( public static member function )

compare

Compare sequences of characters ( public static member function )

find

Find first occurrence of character ( public static member function )

move

Move character sequence ( public static member function )

copy

Copy character sequence ( public static member function )

eof

End-of-File character ( public static member function )

not_eof

Not End-of-File character ( public static member function )

to_char_type

To char type ( public static member function )

to_int_type

To int type ( public static member function )

eq_int_type

Compare int_type values ( public static member function )

© 著作权归作者所有

zray4u
粉丝 0
博文 217
码字总数 188982
作品 0
西城
私信 提问
Shell脚本——cat/EOF输出多行

在某些场合,可能我们需要在脚本中生成一个临时文件,然后把该文件作为最终文件放入目录中。(可参考ntop.spec文件)这样有几个好处,其中之一就是临时文件不是唯一的,可以通过变量赋值,也...

吴伟祥
2018/12/17
92
0
shell调用ftp(sftp)实现自动批量上传(下载)

最近项目需要自动FTP批量上传文件或下载文件。最快的完成方式就是在shell里调用相关的命令,并用crontab调用shell脚本实现周期性FTP批理处理。 当前流行的FTP分为 ftp vs sftp,关于这二者的...

01010101010101010101
2014/05/08
10.3K
0
getchar()和EOF总结(转载)

大师级经典的著作,要字斟句酌的去读,去理解。以前在看K&R的The C Programming Language(SecondEdition) 第1.5节的字符输入/输出,被getchar()和EOF所迷惑了。可能主要还是由于没有搞清楚g...

长平狐
2013/01/06
53
0
c语言初学者的问题关于getchar()!=EOF的验证问题

在Windows7的环境下运行GCC编译THE C Programmer Language课本上的示例,出现问题,难以理解。 #include int main() { int c; while((c=getchar())!=EOF) putchar(c); } 上述中的例子运行正常...

gb356
2016/11/23
293
4
Golang 解决"Connection reset by peer"或"EOF"问题

【问题】 我编写了一个http Client程序代码如下: 多次发给服务器后,几乎每次都会出现下面的错误: 【原因】 在解决问题之前需要了解关于go是如何实现connection的一些背景小知识:有两个协...

吃一堑消化不良
2016/12/19
4.3K
2

没有更多内容

加载失败,请刷新页面

加载更多

java通过ServerSocket与Socket实现通信

首先说一下ServerSocket与Socket. 1.ServerSocket ServerSocket是用来监听客户端Socket连接的类,如果没有连接会一直处于等待状态. ServetSocket有三个构造方法: (1) ServerSocket(int port);...

Blueeeeeee
18分钟前
2
0
用 Sphinx 搭建博客时,如何自定义插件?

之前有不少同学看过我的个人博客(http://python-online.cn),也根据我写的教程完成了自己个人站点的搭建。 点此:使用 Python 30分钟 教你快速搭建一个博客 为防有的同学不清楚 Sphinx ,这...

王炳明
昨天
4
0
黑客之道-40本书籍助你快速入门黑客技术免费下载

场景 黑客是一个中文词语,皆源自英文hacker,随着灰鸽子的出现,灰鸽子成为了很多假借黑客名义控制他人电脑的黑客技术,于是出现了“骇客”与"黑客"分家。2012年电影频道节目中心出品的电影...

badaoliumang
昨天
13
0
很遗憾,没有一篇文章能讲清楚线程的生命周期!

(手机横屏看源码更方便) 注:java源码分析部分如无特殊说明均基于 java8 版本。 简介 大家都知道线程是有生命周期,但是彤哥可以认真负责地告诉你网上几乎没有一篇文章讲得是完全正确的。 ...

彤哥读源码
昨天
13
0
jquery--DOM操作基础

本文转载于:专业的前端网站➭jquery--DOM操作基础 元素的访问 元素属性操作 获取:attr(name);$("#my").attr("src"); 设置:attr(name,value);$("#myImg").attr("src","images/1.jpg"); ......

前端老手
昨天
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部