Visual c++ 使用c++;代码
我试图写一个代码,应该能够使任何格式的文件副本。目前,我正在尝试.pdf格式。以下是我编写的代码:Visual c++ 使用c++;代码,visual-c++,networking,Visual C++,Networking,我试图写一个代码,应该能够使任何格式的文件副本。目前,我正在尝试.pdf格式。以下是我编写的代码: #include <iostream> #include <fstream> using namespace std; int main() { ifstream in("a.pdf", ios::binary); if(in.fail()) { cout<<"\nThe file couldn't be opened\n"; exit(0);
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("a.pdf", ios::binary);
if(in.fail())
{
cout<<"\nThe file couldn't be opened\n";
exit(0);
}
ofstream out("b.pdf", ios::binary);
while(!in.eof())
{
char buf[1000];
in.read(buf, sizeof(buf));
out<<buf;
}
in.close();
out.close();
return 0;
}
#包括
#包括
使用名称空间std;
int main()
{
ifstream-in(“a.pdf”,ios::binary);
if(in.fail())
{
cout我认为发生这种情况是因为您使用的是operatorYeah,它在使用out之后工作得非常好。write(buf,size(buf)),而不是out
while(!in.eof())
{
char buf[1000];
in.read(buf, sizeof(buf));
out.write(buf, sizeof(buf));
}