这是我的代码:
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char * argv[])
{
char * inputFileName = new char ;
char * outputFileName = new char ;
*(inputFileName)='\0';
*(outputFileName)='\0';
if(argc!=3)
{
cout<<"\n\nWRONG SET OF ARGUMENTS!!\n\nSYNTAX:\n"<<endl;
cout<<"\n./FileCp <SOURCE> <DESTINATION>\n"<<endl;
return 1;
}
strcpy(inputFileName,argv[1]);
strcpy(outputFileName,argv[2]);
cout<<"Input File Name = "<<inputFileName<<endl ;
cout<<"Output File Name = "<<outputFileName<<endl ;
}
这是我使用的命令:
./FileCp /Users/sumanthdamarla/Downloads/20130530_235557.jpg jkhs.jpg
这是输出:
Input File Name = /Users/sumanthdajkhs.jpg
Output File Name = jkhs.jpg
inputFileName 被 outputFileName 覆盖。如何解决这个问题?