文件copy与指针数组问题,给分,很急,在线等
我的源程序如下:# include "fstream.h"
# include "iostream.h"
# include "string.h"
int open(int argc,char *argv[])
{
char ch;
//argc = 3;
//argv[1] = "c:\\a.txt";
//argv[2] = "c:\\b.txt";
//cout<<argv[1]<<" "<<argv[2]<<endl;
if(argc!=3)
{
cout<<"error,you shall use this programe as:\n\t"
<<"mycopy filename1 filename2"<<endl;
return 1;
}
ifstream myin(argv[1]);
if (!myin)
{
cout<<"cant open "<<argv[1]<<" for input"<<endl;
return 1;
}
ofstream myout(argv[2]);
if (!myout)
{
cout<<"cant open "<<argv[2]<<"for output"<<endl;
return 1;
}
while(myout&&myin.get(ch))
{
myout.put(ch);
//cout<<"sucess"<<endl;
}
myin.close();
myout.close();
return 0;
}
void main()
{
//int i=3;
char *a[100];
//for (int i=1;i<=2;i++)
//{
// a[i] = "c:\\"+str(i)+".txt";
//}
// open(i,*a[]);
a[0] = "c:\\a.txt";
a[1] = "c:\\b.txt";
int c = open(3,*a);//error
if (c==1)
{
cout<<"false"<<endl;
}
else
{
cout<<"sucess"<<endl;
}
}
//请帮忙修改一下,谢谢各位大侠了