
请问怎么用C++将一个屏幕的内容放到另一个txt中。(描述的可能不是太好)谢谢 15
intmain(char*a){ifstreamfile("d:\\file.txt",ios::in);char*str=newchar[sizeoffile];//动...
int main(char *a)
{
ifstream file("d:\\file.txt",ios::in);
char * str=new char[sizeof file]; //动态创建字符串数组
for(;!file.eof(); {
file.getline(str,sizeof file);//将数据读入到str中
cout<<str<<endl;
}system("Pause");//这个地方也请帮忙改一下。不加这个好像就成了死循环
file.close();
return 0;
}
就是将file的内容放到另一个txt里。 展开
{
ifstream file("d:\\file.txt",ios::in);
char * str=new char[sizeof file]; //动态创建字符串数组
for(;!file.eof(); {
file.getline(str,sizeof file);//将数据读入到str中
cout<<str<<endl;
}system("Pause");//这个地方也请帮忙改一下。不加这个好像就成了死循环
file.close();
return 0;
}
就是将file的内容放到另一个txt里。 展开
2个回答
展开全部
我学的是c,用c的方法就是打开另一个文件,输出到里面.
用系统调用的方法就是system(echo str > b.txt);
你试试
用系统调用的方法就是system(echo str > b.txt);
你试试
追问
谢谢~是C语言么,我先试试,请问echo是什么?
追答
echo在cmd脚本中是输出在屏幕的意思
展开全部
我在VC6下试了下,不会死循环的
ifstream file("file.txt",ios::in);
char * str=new char[sizeof(file)]; //动态创建字符串数组
for(;!file.eof();)
{
file.getline(str, sizeof(file) );
cout<<str<<endl;
}
// system("Pause");
file.close();
return 0;
ifstream file("file.txt",ios::in);
char * str=new char[sizeof(file)]; //动态创建字符串数组
for(;!file.eof();)
{
file.getline(str, sizeof(file) );
cout<<str<<endl;
}
// system("Pause");
file.close();
return 0;
追问
我在vs2010里试了一下,还是死循环的。
那个再问一下,怎么获得运行屏幕的内容(是直接显示的,不是键盘输入的)
追答
控制台是有个缓冲区的,控制那个挺麻烦的,还是想想有没有其他解决方案
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询