Home > Software engineering >  The access unnamed file, try over the ending
The access unnamed file, try over the ending

Time:09-23

Void CAR: : count_read ()
{
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 use

CodePudding user response:

To the operation of the CFile file with the try catch catch CFileException

CodePudding user response:

But this is not the problem, because before I didn't have this mistake

CodePudding user response:

To set breakpoints in commissioning,

CodePudding user response:

The way I now switch to the C language a
Void 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
  • Related