关于变量申明的问题?
源程序:
......
__declspec( dllexport ) int WINAPI convert(char *key, unsign char* infile, unsign char* outfile, char flag)
{
long FileLen=0;
div_t FileCount;
CFile Fileoper;
CFile Fileoper1;
unsigned char* inchar=NULL;
unsigned char* outchar=NULL;
long iRet=0;
if (Fileoper.Open((const char*)infile, CFile::modeRead, NULL)==0)
{
return -1;
}
if (Fileoper1.Open((const char *)outfile,CFile::modeCreate, NULL)==0)
{
return -1;
}
FileLen=Fileoper.GetLength();
FileCount=div(FileLen,8);
Fileoper.SeekToBegin();
for (int i=1;i<FileCount.quot;i++)
{
iRet=Fileoper.Read(inchar,8);
if (iRet!=8)
{
return -1;
}
if (flag==0)
{
iRet=mycrypt(key,inchar,outchar);
if(iRet<0)
{
return -1;
}
}
if(flag==1)
{
iRet=unmycrypt(key,inchar,outchar);
if(iRet<0)
{
return -1;
}
}
iRet=Fileoper.Seek(8,CFile::current);
if(iRet<0)
{
return -1;
}
Fileoper1.Write(outchar,8);
}
if(FileCount.rem!=0)
{
iRet=Fileoper.Read(inchar,FileCount.rem);
if(iRet<0)
{
return -1;
}
Fileoper1.Write(outchar,FileCount.rem);
}
Fileoper.Close();
Fileoper1.Close();
return 1;
}
......
修改为
__declspec( dllexport ) int WINAPI convert(char *key, CString& infile, CString& outfile, char flag)
{
long FileLen=0;
div_t FileCount;
CFile Fileoper;
CFile Fileoper1;
unsigned char* inchar=NULL;
unsigned char* outchar=NULL;
long iRet=0;
if (Fileoper.Open( infile, CFile::modeRead, NULL)==0)
{
return -1;
}
if (Fileoper1.Open(outfile,CFile::modeCreate, NULL)==0)
{
return -1;
}
FileLen=Fileoper.GetLength();
FileCount=div(FileLen,8);
Fileoper.SeekToBegin();
for (int i=1;i<FileCount.quot;i++)
{
iRet=Fileoper.Read(inchar,8);
if (iRet!=8)
{
return -1;
}
if (flag==0)
{
iRet=mycrypt(key,inchar,outchar);
if(iRet<0)
{
return -1;
}
}
if(flag==1)
{
iRet=unmycrypt(key,inchar,outchar);
if(iRet<0)
{
return -1;
}
}
iRet=Fileoper.Seek(8,CFile::current);
if(iRet<0)
{
return -1;
}
Fileoper1.Write(outchar,8);
}
if(FileCount.rem!=0)
{
iRet=Fileoper.Read(inchar,FileCount.rem);
if(iRet<0)
{
return -1;
}
Fileoper1.Write(outchar,FileCount.rem);
}
Fileoper.Close();
Fileoper1.Close();
return 1;
}
但修改后传进去的参数就不对了,请问这是什么原因?