Home > Software engineering >  Save a file according to the line in another file
Save a file according to the line in another file

Time:10-27


This file, put the Numbers for * the NODE to NODE. In the text, put the data after * INITIAL_VELOCITY_NODE V.t ext in
# define KEY1 "* NODE
"# define KEY2 "* INITIAL_VELOCITY_NODE
"# define KEY3 "* END
"using namespace std;
Int main ()
{
Const int LINE_LENGTH=100;
Char STR [LINE_LENGTH];
Char buffer [LINE_LENGTH];
Int line=0;
The FILE * fp1=fopen (" F: \ \ node TXT ", "w");
The FILE * fp2=fopen (" F: \ \ V.t xt ", "w");
Ifstream infile (" jet. K ");
] getline (infile, STR);
while(! Infile. Eof ())
{
If (STRCMP (STR, KEY1)==0)
{
While (STRCMP (STR, KEY2)==0)
{
Memset (STR, 0, sizeof (STR));
Getline (infile, STR);
Line++;
Fprintf (fp1, "% s \ n", STR);
}
}
If (STRCMP (STR, KEY2)==0)
{
While (STRCMP (STR, KEY3)==0)
{
Memset (STR, 0, sizeof (STR));
Getline (infile, STR);
Fprintf (fp2, "% s \ n", STR);
}
}
}
Infile. Close ();
}

CodePudding user response:

Find * NODE is most starting point, Find the end point, * INITIAL_VELOCITY_NODE to intercept and then written to the file
Find * INITIAL_VELOCITY_NODE as a starting point, the end point, a borrow to intercept and then written to the file
  • Related