| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1672 人关注过本帖
标题:请教一个特业余而我却弄不明白的C++问题
只看楼主 加入收藏
wangsong
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2006-7-15
收藏
得分:0 
以下是引用woodhead在2006-7-21 11:55:33的发言:
cin 是一个对象,它有一些方法,有自己的状态,
>>其实是一个函数,word是这个函数的一个参数。
要想仔细了解cin,需要一些类型方面的知识,一句两句讲不清。
是的,但要搞清楚它

2006-07-21 20:32
Rosina
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-7-22
收藏
得分:0 
string word;
while(cin>>word,word!="#") //调处循环的条件由自己控制
{
}

2006-07-22 23:41
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
呵呵
是缓冲区问题

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-07-23 00:31
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
教C时老师说过关于scanf缓冲区BUG
和这个类似

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-07-23 00:32
ysol
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2006-6-11
收藏
得分:0 

最简单方法ctrl+c
不管什么循环直接跳出。

2006-07-24 02:51
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
wfpb,

i have just try a demo code, like this:

#include <string>
#include <iostream>
using namespace std;

int main()
{
string word;
while(cin>>word)
{
cout<<word<<" ";
}
return 0;
}

I have testet with using gcc compile. It is ok, i need just one time to type ctrl + z, not two times. I guess, you used VC ,and the reason for that is the using of VC. VC hat some Bug in IO

自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-07-24 08:32
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 

End-of-file

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computing, end-of-file, commonly abbreviated EOF, is a condition in a computer operating system where no more data can be read from a data source. The data source is usually called a file or stream.

In the C programming language, or more correctly, the C Standard Library, file access and other I/O functions may return a value equal to the symbolic value (macro) EOF to indicate that an end-of-file condition has occurred. The actual value of EOF is commonly -1, but is system-dependent. The macro EOF is expanded to the actual value by a preprocessor before compiling the source code.

In UNIX an end-of-file indication can be sent from an interactive shell (console) by typing Ctrl+D (conventional standard). In Microsoft's DOS and Windows it is sent by pressing Ctrl+Z. In certain cases when dealing with text files or reading data from a "character device", the Microsoft MS-DOS shell (COMMAND.COM) or operating-system utility programs would historically append an ASCII Control-Z character to the end of a disk file (though the basic kernel MSDOS.SYS file write calls never appended a Control-Z). This was done for backward compatibility with some of the peculiarities of CP/M, since the CP/M filesystem only recorded the lengths of files in terms of how many 128-byte "records" were allocated. The MS-DOS filesystem has always recorded the exact byte-length of files from its very first version.

ASCII control characters are out-of-band non-printing characters in a character stream. They are normally represented by a more readable mnemonic.


自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-07-24 08:53
快速回复:请教一个特业余而我却弄不明白的C++问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059098 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved