)
错误代码:
#include "stdafx.h"
#include "Test6.h"
CString GetFileName(CString strFile){
OutputDebugString(strFile);
int nPos = strFile.ReverseFind(_T('.'));
return strFile.Right(strFile.GetLength() - nPos -1);
}
void PrintTest(CString strFile){
OutputDebugString(strFile);
{
CString strFile = GetFileName(strFile);
}
OutputDebugString(strFile);
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
PrintTest(_T("D:\\users\\Desktop\\Tablet.dwg"));
return 0;
}
调试参数异常显示
错误原因
传入的strFile和临时变量strFile冲突导致
代码修正
#include "stdafx.h"
#include "Test6.h"
CString GetFileName(CString strFile){
OutputDebugString(strFile);
int nPos = strFile.ReverseFind(_T('.'));
return strFile.Right(strFile.GetLength() - nPos -1);
}
void PrintTest(CString strFile){
OutputDebugString(strFile);
{
CString strFileName = GetFileName(strFile);
}
OutputDebugString(strFileName);
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
PrintTest(_T("D:\\users\\Desktop\\Tablet.dwg"));
return 0;
}