Click here to Skip to main content
15,917,964 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

The following code causing an exception in visual studio 2005.It is working fine

with visual studio 2003.


-----------------------------------------------------------------------------------
C++
void CDeleteIt100Dlg::OnBnClickedOk()
{
	CString strPath1 = _T("pc106");
	CString strPath2 = _T("E:\INETPUB\WWWROOT\OrchestraCM");
	Test(strPath1,strPath2);
	OnOK();
}
void CDeleteIt100Dlg::Test(CString &strPath1,CString &strPath2)
{
	try
	{
		CString str;
		str.Format(_T("\\\\%s%\\%s"),strPath1,strPath1);
	}
	catch(CException *exc)
	{
		int a = GetLastError();
	}
	
}



-----------------------------------------------------------------------------------

The above code causing an exception as


---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: ...
File: f:\rtm\vctools\crt_bld\self_x86\crt\src\output.c
Line: 1123

Expression: (state != ST_INVALID)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

---------------------------------------------------------------------------------


Please help me.


Thanks in advance.
Posted
Updated 29-Jul-11 2:32am
v3
Comments
Richard MacCutchan 29-Jul-11 7:46am    
Which line of your code causes the exception?
kutz 2 29-Jul-11 7:48am    
str.Format(_T("\\\\%s%\\%s"),strPath1,strPath1);

1 solution

normally % is used as a format specifier. You have used '%\' within the line
str.Format(_T("\\\\%s%\\%s"),strPath1,strPath1);


This is not a valid format specifier, Please change that to a valid one depends on what u actually need.
Also see http://msdn.microsoft.com/en-us/library/75w45ekt(v=vs.80).aspx[^]
 
Share this answer
 
Comments
kutz 2 29-Jul-11 8:13am    
Oops I just watched this "%" infront of "\\".Thanks it is working fine now.But why it is working fine in VS2003?
barneyman 29-Jul-11 8:21am    
presumably MS changed the way they parse for tokens between CRT versions
kutz 2 29-Jul-11 8:31am    
Ok Thanks for all of your information.
Richard MacCutchan 29-Jul-11 8:38am    
+5; well spotted, I missed that.
Sergey Alexandrovich Kryukov 2-Aug-11 4:39am    
Agree, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900