Home > Back-end >  Ask why ifstream read data, the last column data can't read the whole
Ask why ifstream read data, the last column data can't read the whole

Time:09-25

The output data:
Int write_check_fluid ()
{
int i, j;

Ofstream fout.

Fout. Open (". \ \ check_fluid dat ", the ios: : out | ios: : trunc);


if (! Fout)
{
Cout & lt; <"Failed in opening a fluid field file: check_fluid." & lt; exit(0);
}
The else
{
Fout & lt; Fout & lt;
For (I=0; i <=Nx; I++)
For (j=0; J & lt;=Ny; J++)
{
Fout & lt; }


Fout. Close ();
}


return 0;

}

Read data:
Int read_check_fluid ()
{
int i, j;

Ifstream fin;
Fin. Open (". \ \ check_fluid dat ", the ios: : | in ios: : binary);
char ch;


if (! Fin. Is_open ())
{
Cout & lt; <"To Simulate the from a new initial fluid field." & lt;
Step0=1;
T0=0.
For (I=0; i For (j=0; J & lt; Ny; J++)
{
U_g [I] [j] [0]=0.0;
U_g [I] [j] [1]=0.0;
P_g [I] [j]=rhof * (c_g * c_g)/(3);
//p_g [I] [j]=rhof * (c_g * c_g)/(3) + dp (0.5 * 1.0 * x2/NxT * dp);
}

return 0;
}
The else
{
Fin & gt;> Step0;
Fin & gt;> T0;

For (I=0; i <=Nx; I++)
For (j=0; J & lt;=Ny; J++)
Fin & gt;> U_g [I] [j] [0] & gt;> Ch & gt;> U_g [I] [j] [1] & gt;> Ch & gt;> P_g [I] [j];


Fin. The close ();

}

return 0;
}


Read the data, the last column p_g [I] [j] incomplete data, the highest two data loss, consult warrior, why, thank you!
  • Related