{
CFile file;
CFileException fe;
if (! File. The Open (_T (" G: \ \ P \ \ PRO \ \ car_count. TXT "), CFile: : modeRead, & amp; Fe))
{
Fe. ReportError ();
return;
}
CArchive ar (& amp; The file, CArchive: : load);
File. SeekToBegin ();
Ar & gt;> The count.
Ar. Flush ();
Ar. The Close ();
File. The Close ();
}
I'm writing a vehicle management system, but do not know why to join this function after always have this problem, this function is read from a file the number of vehicles, vehicle number CAR: : count is a static variable, it is also be declared as static function, this function is to the number of the CAR are out,
In a digital file
The location of the calling function, in this
Void CPRODlg: : OnBnClickedButton1 ()
{
//registration information bounced
If (NULL==m_add)
{
M_add=new ADD ();
M_add - & gt; Create (IDD_ADDITION, this);
}
M_add - & gt; ShowWindow (SW_SHOW);
//read the number of vehicles
CAR: : count_read ();
}
CodePudding user response:
Bumps, ask for help.CodePudding user response:
Bosses for help ah, curriculum design should useCodePudding user response:
To the operation of the CFile file with the try catch catch CFileExceptionCodePudding user response:
But this is not the problem, because before I didn't have this mistakeCodePudding user response:
To set breakpoints in commissioning,CodePudding user response:
The way I now switch to the C language aVoid CAR: : count_read ()
{
FILE *fp;
Fp=fopen (" G: \ \ P \ \ PRO \ \ car_count. TXT ", "r");
The fscanf (fp, "% d", & amp; CAR: : count);
}
}
CodePudding user response:
//
CStdioFile file;
TMP. TXT file. Open (" ", CFile: : modeRead);
CArchive ar (& amp; The file, CArchive: : load);
//
Cstrings STR.
Ar. ReadString (STR);
Ar. Flush ();
Ar. The Close ();
File. The Close ();
Printf (" % s \ n ", STR);
CodePudding user response:
//'& gt;> 'only for primitive types. No string