|
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
各位大佬好! 这是我写的程序;程序功能可以实现,
就是不知道怎么用程序新建一个txt文件 以及怎么拷贝空格字符;
int _tmain(int argc, _TCHAR* argv[])
{
ifstream ifs("e:\\123.txt");
ofstream ofs("e:\\456.txt");
if (!ifs || !ofs)
{
cout<<"error"<<endl;
ifs.close(); ofs.close(); return 0;
}
char i[100];
for (int j = 0;!ifs.eof();)
{
ifs >> i;
ofs << i<<endl;
memset(i, 0, 100);
}
ifs.close();
ofs.close();
return 0;
}
ofstream ofs("e:\\456.txt");
默认这样的话,如果 e 盘下面没有 465.txt 的话就会自动创建一个啊!
另外,写入空格的话也很简单:ofs << " "; 这样就可以了
|
上一篇: 一个多线程的问题求助下老大下一篇: C++学习疑问
|