Input and output of iostream.
来源:互联网 发布:黄日华 天龙八部 知乎 编辑:程序博客网 时间:2024/06/10 07:33
Output:
1.
const char * p = ?;
cout<< static_cast<void *>(const_cast<char *> (p));
.
2.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
string pooh_pals[] = {
"Tigger", "Piglet", "Eeyore", "Rabbit"
};
int main()
{
vector<string> ppals( pooh_pals, pooh_pals+4 );
vector<string>::iterator iter = ppals.begin();
vector<string>::iterator iter_end = ppals.end();
cout « "These are Pooh's pals: ";
// copies each element to cout ...
ostream_iterator< string > output( cout, " " );
copy( iter, iter_end, output );
cout « endl;
}
Input:
1.
There are two general conditions under which an istream evaluates to false:
either the end-of-file is read (in which case we have
read correctly all the values contained within the file) or an invalid value has been encountered
2.
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
int main()
{
istream_iterator< string > in( cin ), eos ;
vector< string > text ;
// copy the values read from standard input into text
copy( in , eos , back_inserter( text ) ) ;
sort( text.begin() , text.end() ) ;
// remove all duplicate values
vector< string >::iterator it ;
it = unique( text.begin() , text.end() ) ;
text.erase( it , text.end() ) ;
// display the resulting vector
int line_cnt = 1 ;
for ( vector< string >::iterator iter = text.begin();
iter != text.end() ; ++iter , ++line_cnt )
cout « *iter
« ( line_cnt % 9 ? " " : "/n" ) ;
cout « endl;
}
(For more information, please see ref )
(For more information, please see ref )
ostream out("out.bat");
ostream out("out.bat");
cout = out;
2.
#include <cstdlib> // Declare "system()"
int main()
{
system("
a > in.txt < out.txt
");
}
a > in.txt < out.txt
a > in.txt < out.txt
Replace char * with string
The benefit of string with char *:
You need not manage memory.
3.
}
a > in.txt < out.txt
int main()
{
system("
a > in.txt < out.txt
");
a > in.txt < out.txt
#include <cstdlib> // Declare "system()"
cout = out;
1.
IO Rederict:
const char * p = ?;
- Input and output of iostream.
- input and output
- itk input and output
- Python input and output
- Input and Output
- 7. Input and Output
- 8 Input and Output
- Ch.7 - Input and Output
- Hadoop Streaming Input and Output
- Redirecting standard input and output
- File Input and Output(1)
- Standard Input and Output Redirection
- I/O Input and Output
- [Language]File Input and Output
- 14.2. Input and Output Operators
- Synchronization and Overlapped Input and Output
- Linux - Redirection of Standard output/input
- I/O of python (INPUT / OUTPUT)
- 程序员24不该
- 第一次发表Blog的收藏文章。
- MySQL在Win2000下的安装
- 第二次发表收藏文章。
- 我的第一次
- Input and output of iostream.
- 20060110
- eclipse安装与配置
- 树型结构数据在关系数据库中用链式存储相关查询实现
- 新年快乐
- tomcat插件安装
- 好久都没有来这个我们共同交流的地方了
- 1002 。
- When Element add attribute by the method "setAttribute",It can't work in IE