![]() |
#2
书生牛犊2016-08-12 16:45
|

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
ifstream infile;
ofstream outfile;
char name[20];
char c;
cout<<"please entra filename"<<endl;
cin>>name;
infile.open(name);
if(!infile)
{
cout<<"failure"<<endl;
exit(1);
}
cout<<"start copy"<<endl;
stract(name,"copyfile");
outfile.open(name);
if(!outfile)
{
cout<<"can not copy"<<endl;
exit(1);
}
while(!outfile.eof())
{
infile.get(c);
cout<<c;
}
cout<<endl;
infile.close();
outfile.close();
return 0;
}
23 27 E:\CPP\数据结构\test.cpp [Error] 'stract' was not declared in this scope#include <fstream>
#include <cstring>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
ifstream infile;
ofstream outfile;
char name[20];
char c;
cout<<"please entra filename"<<endl;
cin>>name;
infile.open(name);
if(!infile)
{
cout<<"failure"<<endl;
exit(1);
}
cout<<"start copy"<<endl;
stract(name,"copyfile");
outfile.open(name);
if(!outfile)
{
cout<<"can not copy"<<endl;
exit(1);
}
while(!outfile.eof())
{
infile.get(c);
cout<<c;
}
cout<<endl;
infile.close();
outfile.close();
return 0;
}
stract没定义应该是头文件的原因吧,但是我在头文件定义了cstring,这个相当于string.h
.