#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
ifstream in_file ("f:\text.txt");
if (!in_file)
{
cerr<<"oops!unable to open input file\n";return -1;
}
ofstream out_file("f:\text.sort");
if(!out_file)
{
cerr<<"oops!unable to open output file\n";return -2;
}
string word;
vector <string>text;
while(in_file>>word)
text.push_back (word);
int ix;
cout<<"unsorted text:\n";
for (ix=0;ix<text.size();++ix)
cout <<text[ix]<<'';
cout << endl;
sort(text.begin (),text.end ());
out_file<<"sorted text:\n";
for (ix=0;ix<text.size ();++ix)
out_file<<text[ix]<<'';
out_file <<endl;
return 0;
}
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
ifstream in_file ("f:\text.txt");
if (!in_file)
{
cerr<<"oops!unable to open input file\n";return -1;
}
ofstream out_file("f:\text.sort");
if(!out_file)
{
cerr<<"oops!unable to open output file\n";return -2;
}
string word;
vector <string>text;
while(in_file>>word)
text.push_back (word);
int ix;
cout<<"unsorted text:\n";
for (ix=0;ix<text.size();++ix)
cout <<text[ix]<<'';
cout << endl;
sort(text.begin (),text.end ());
out_file<<"sorted text:\n";
for (ix=0;ix<text.size ();++ix)
out_file<<text[ix]<<'';
out_file <<endl;
return 0;
}
解决方案 »
- 探求软件发展的未来!
- 如何动态生成类急今晚就要
- 求救:如何知道ROM中的盘片是CD Disk还是DVD Disk呢
- 怎样用jmail发送邮件?
- 我创建了一个基于CButton的类CMyButton,我想用bitmap或icon来显示,在drawitem里该怎么写?
- 请问如何在SETWINDOWTEXT里输入换行!
- 感谢zhang865的帮助,开贴给分!
- 散分(原因在里面)
- 如何使对话框的背景色变成透明色?
- 能否不用proxy/stub,就可以在vb/vc中使用结构
- CompleteWord的快捷键是不是Ctrl+Space?为什么不起作用?
- 我的表格控件在行列过大的时候为什么MemDC.CreateCompatibleDC(pdc)失败?
这个程序就是Essential C++书中209页的练习1.7
希望大家看一看为编译后出错!
F:\vc³ÌÐò\cpp6.cpp(33) : error C2137: empty character constant
Error executing cl.exe.
这就是错误
怎么修改?