c++文件流问题。为什么用ifstream infile(source,ios::binary);没打开文件
我想把E盘的名为11的图片复制到G盘,取名12.可是测试后发现找不到E盘的11.谁帮我看看,顺便看下我后面的语句是不是对的。谢了#include<iostream>#in...
我想把E盘的名为11的图片复制到G盘,取名12.
可是测试后发现找不到E盘的11.谁帮我看看,顺便看下我后面的语句是不是对的。谢了
#include <iostream>#include <fstream>using namespace std;void main(){ char i; char source[256]; char destination[256]; cout<<"输入源文件"<<endl; cin>>source; cout<<"输入目标文件"<<endl; cin>>destination; ifstream infile(source,ios::binary); if(! infile) { cerr<<"no found "<<endl; exit(1); } ofstream outfile(destination,ios::binary);while(1){
infile.read((char *)&i,sizeof(int)); outfile.write((char *)&i,sizeof(int)); if(outfile.eof) break;}
infile.close(); outfile.close(); } 展开
可是测试后发现找不到E盘的11.谁帮我看看,顺便看下我后面的语句是不是对的。谢了
#include <iostream>#include <fstream>using namespace std;void main(){ char i; char source[256]; char destination[256]; cout<<"输入源文件"<<endl; cin>>source; cout<<"输入目标文件"<<endl; cin>>destination; ifstream infile(source,ios::binary); if(! infile) { cerr<<"no found "<<endl; exit(1); } ofstream outfile(destination,ios::binary);while(1){
infile.read((char *)&i,sizeof(int)); outfile.write((char *)&i,sizeof(int)); if(outfile.eof) break;}
infile.close(); outfile.close(); } 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询