System (" CLS ");
COURSE * pt=new COURSE;
Char no [20].
Ifstream inFile (" fCourse. TXT ", the ios: : binary | ios: : in);
if(! InFile)
{
Cout<" File open exception!"
Cout<" If input change student student id: "& lt;
if(! InFile)
Cout<" File open failed!"
{
while(! InFile. Eof ())
{
InFile. Read (reinterpret_cast & lt; Char * & gt; (pt), sizeof (COURSE));
//inFile> STU.
If (STRCMP (pt - & gt; Cour_num, no)==0)
{
//strncpy (sTemp - & gt; CName, STU, 7);
//inFile> STemp - & gt; CNo> STemp - & gt; CName> STemp - & gt; CSex> STemp - & gt; NYear> STemp - & gt; NMonth> STemp - & gt; NDay> STemp - & gt; CMajor;
If (inFile. Gcount ()!=0)
Cout<" T \ \ t \ t * * * * * * this course basic information "& lt;
}
}
COURSE * p=new COURSE + 1;
InFile. Close ();
Cout<" Whether to modify course information? (1, 0 no) "& lt;
Cin> i;
If (I==0)
{
System (" pause ");
The menu ();
}
The else
{
Ofstream outFile (" fCourse. TXT ", the ios: : out);
OutFile. Seekp (sizeof (p), the ios: : cur);
Cout<" Please input the modified information: "& lt;
Cin> P - & gt; Cour_num;
Cout<" Course name: ";
Cin> P - & gt; Cour_name;
Cout<" Course credits: ";
Cin> P - & gt; Cour_score;
Cout<" Course nature: ";
Cin> P - & gt; Cour_Feature;
OutFile. Write (reinterpret_cast & lt; Char * & gt; (p), sizeof (COURSE));
OutFile. Close ();
CodePudding user response:
OutFile. Seekp (sizeof (p), the ios: : cur);Ios: : cur have changed the current position?