.NET issue
-
The following code works in VS 6 debug/release. Works in debug in VS .NET, but locks up in release.
CString Desc; // All others are double while ( fscanf (LoadFile, "%lf %lf %lf %lf %lf %d %[_0-9 a-zA-Z]", &m_dTemp, &m_dIce, &m_dWind, &m_dTension, &m_dK, &m_iCode, Desc) != EOF) { m_cboLoads.AddString( cDesc ); }
The fscanf is causing the lock up with the CString. Any ideas, or avenues of research? thanks -
The following code works in VS 6 debug/release. Works in debug in VS .NET, but locks up in release.
CString Desc; // All others are double while ( fscanf (LoadFile, "%lf %lf %lf %lf %lf %d %[_0-9 a-zA-Z]", &m_dTemp, &m_dIce, &m_dWind, &m_dTension, &m_dK, &m_iCode, Desc) != EOF) { m_cboLoads.AddString( cDesc ); }
The fscanf is causing the lock up with the CString. Any ideas, or avenues of research? thanksConvert your program to C++ ? Seriously, C file handling is SO ugly. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
Convert your program to C++ ? Seriously, C file handling is SO ugly. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
Yes, I have been putting that off. What is best way to read formated text from a file with c++. Example:
0.00 0.50 4.00 0.600 0.30 1 NESC Heavy 32.00 0.50 0.00 0.000 0.00 0 32 Deg -20.00 0.00 0.00 0.000 0.00 0 Uplift 60.00 0.00 0.00 0.350 0.00 1 Load 60.00 0.00 0.00 0.250 0.00 2 No Wind 60.00 0.00 0.00 0.000 0.00 2 CREEP CHECK 90.00 0.00 0.00 0.000 0.00 0 90 Deg F 120.00 0.00 0.00 0.000 0.00 0 120 Deg F 167.00 0.00 0.00 0.000 0.00 0 167 Deg F 212.00 0.00 0.00 0.000 0.00 0 212 Deg F 302.00 0.00 0.00 0.000 0.00 0 HOT
-
Yes, I have been putting that off. What is best way to read formated text from a file with c++. Example:
0.00 0.50 4.00 0.600 0.30 1 NESC Heavy 32.00 0.50 0.00 0.000 0.00 0 32 Deg -20.00 0.00 0.00 0.000 0.00 0 Uplift 60.00 0.00 0.00 0.350 0.00 1 Load 60.00 0.00 0.00 0.250 0.00 2 No Wind 60.00 0.00 0.00 0.000 0.00 2 CREEP CHECK 90.00 0.00 0.00 0.000 0.00 0 90 Deg F 120.00 0.00 0.00 0.000 0.00 0 120 Deg F 167.00 0.00 0.00 0.000 0.00 0 167 Deg F 212.00 0.00 0.00 0.000 0.00 0 212 Deg F 302.00 0.00 0.00 0.000 0.00 0 HOT
I'd use a struct so I could stream them in one go - read my article on iostream inserters and extrators. The problem would be that your string at the end is able to have a space in it. There are multiple ways to handle this, but the first that comes to mind is to read the floats in directly, as in #include #include std::ifstream strm("c:\\my file.txt"); float a,b,c,d,e; std::string suffix; while (strm.good()) { strm << a << b << c << d << e; std::getline(strm, suffix); // process each line here } that's off the top of my head, so not guarenteed to be production code, or even to compile :-) You get the idea though. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
The following code works in VS 6 debug/release. Works in debug in VS .NET, but locks up in release.
CString Desc; // All others are double while ( fscanf (LoadFile, "%lf %lf %lf %lf %lf %d %[_0-9 a-zA-Z]", &m_dTemp, &m_dIce, &m_dWind, &m_dTension, &m_dK, &m_iCode, Desc) != EOF) { m_cboLoads.AddString( cDesc ); }
The fscanf is causing the lock up with the CString. Any ideas, or avenues of research? thanksFirst of all i dont know how is this related to dot.net Desc in has not been allocated any string.. so use it this way in the scanf Desc.GetBuffer(20) and after the scanf call Desc.ReleaseBuffer this should work. cheers. The World is getting smaller and so are the people.
-
First of all i dont know how is this related to dot.net Desc in has not been allocated any string.. so use it this way in the scanf Desc.GetBuffer(20) and after the scanf call Desc.ReleaseBuffer this should work. cheers. The World is getting smaller and so are the people.