why doesn't TRACE output correctly?
-
CString strTemp strTemp.Format("%-60s%-20.1f\r\n%-60s%-20.1f\r\n%-60s%-20.1f\r\n","Global Wall",0,"Limiting Potential",0,"Roughness Correlation",0); TRACE("output:%s\n",strTemp); when debugging, the output is: output:Global Wall 0.0 (null) 0.0 ? -2.0 how can i dispose of the problem?
-
CString strTemp strTemp.Format("%-60s%-20.1f\r\n%-60s%-20.1f\r\n%-60s%-20.1f\r\n","Global Wall",0,"Limiting Potential",0,"Roughness Correlation",0); TRACE("output:%s\n",strTemp); when debugging, the output is: output:Global Wall 0.0 (null) 0.0 ? -2.0 how can i dispose of the problem?
Remove "\r". Weiye Chen Life is hard, yet we are made of flesh...
-
CString strTemp strTemp.Format("%-60s%-20.1f\r\n%-60s%-20.1f\r\n%-60s%-20.1f\r\n","Global Wall",0,"Limiting Potential",0,"Roughness Correlation",0); TRACE("output:%s\n",strTemp); when debugging, the output is: output:Global Wall 0.0 (null) 0.0 ? -2.0 how can i dispose of the problem?
-
CString strTemp strTemp.Format("%-60s%-20.1f\r\n%-60s%-20.1f\r\n%-60s%-20.1f\r\n","Global Wall",0,"Limiting Potential",0,"Roughness Correlation",0); TRACE("output:%s\n",strTemp); when debugging, the output is: output:Global Wall 0.0 (null) 0.0 ? -2.0 how can i dispose of the problem?
CString strTemp strTemp.Format("%-60s%-20.1f\r\n%-60s%-20.1f\r\n%-60s%-20.1f\r\n","Global Wall",(float)0.0,"Limiting Potential",(float)0.0,"Roughness Correlation",(float)0.0); // important to case the CString since the TRACE does not know argument type TRACE("output:%s\r\n",(LPCTSTR)strTemp);
-
CString strTemp strTemp.Format("%-60s%-20.1f\r\n%-60s%-20.1f\r\n%-60s%-20.1f\r\n","Global Wall",0,"Limiting Potential",0,"Roughness Correlation",0); TRACE("output:%s\n",strTemp); when debugging, the output is: output:Global Wall 0.0 (null) 0.0 ? -2.0 how can i dispose of the problem?
All you need to do is replace each
0
with0.0
instead. WhenFormat()
encountered the%f
, it attempted to pop afloat
type from the stack but got anint
type instead.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown