{
// TODO: Add your command handler code here
CString sFilename(GetDocument()->GetPathName());
CString sTitle(GetDocument()->GetTitle());
int nTitle=atoi(sTitle);
int nFind;
if ((nTitle>1)&(nTitle<=3))
{
sTitle.Format("%d", nTitle-1 );
nFind = sFilename.ReverseFind('\\\');
if(nFind>0)
{
CString sNewFilename(sFilename.Left(nFind)+ "\\\" + sTitle+".txt" );
AfxGetApp()->OpenDocumentFile(sNewFilename);
}
}
else
AfxMessageBox("没有上一文件了");
}
在nFind = sFilename.ReverseFind('\\\');处报错:error C2001: newline in constant;error C2015:too many characters in constant
为什么呢?
6 个解决方案
#1
'\\\'改成'\\'
#2
'\\'
#3
if ((nTitle>1)&(nTitle<=3))
&的使用有错误吗?
&的使用有错误吗?
#4
&表示按位与,&&表示逻辑与,这里应该是用&&
#5
if ((nTitle>1)&(nTitle<=3))
-->
if ((nTitle>1)&&(nTitle<=3))
你这里是判断nTitle是在(1, 3]之间吧,大于1小于等于3
-->
if ((nTitle>1)&&(nTitle<=3))
你这里是判断nTitle是在(1, 3]之间吧,大于1小于等于3
#6
谢谢!
#1
'\\\'改成'\\'
#2
'\\'
#3
if ((nTitle>1)&(nTitle<=3))
&的使用有错误吗?
&的使用有错误吗?
#4
&表示按位与,&&表示逻辑与,这里应该是用&&
#5
if ((nTitle>1)&(nTitle<=3))
-->
if ((nTitle>1)&&(nTitle<=3))
你这里是判断nTitle是在(1, 3]之间吧,大于1小于等于3
-->
if ((nTitle>1)&&(nTitle<=3))
你这里是判断nTitle是在(1, 3]之间吧,大于1小于等于3
#6
谢谢!