# Read varlues created from FreeFem ofstream

**URL:** <https://community.freefem.org/t/read-varlues-created-from-freefem-ofstream/1899>\
**Category:** General Discussion\
**Created:** [July 19, 2022, 9:16am UTC](https://community.freefem.org/t/read-varlues-created-from-freefem-ofstream/1899 "2022-07-19T09:16:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefanosv](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Stefanosv](https://community.freefem.org/u/Stefanosv)\
**Post date:** [July 19, 2022, 9:16am UTC](https://community.freefem.org/t/read-varlues-created-from-freefem-ofstream/1899/1 "2022-07-19T09:16:38Z")

</div>

I have calculated some values on a .edp and I want to read them on a different one.  
I used the following code to save them

```auto
{ofstream fout("f1.txt");
fout << f1 << endl;
}

```

Most of the files are arrays but one of them is a matrix saved on Hashmatrix type.  
How would you go about on using them on a differend .edp  
[txt.rar](https://community.freefem.org/uploads/short-url/7hB50QMXoL5OQ0l6lVeHF4YFOxX.rar) (40.6 KB)

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [July 23, 2022, 10:34am UTC](https://community.freefem.org/t/read-varlues-created-from-freefem-ofstream/1899/2 "2022-07-23T10:34:10Z")

</div>

just do

```auto
real[int] f1;
ifstream fin("f1.txt");
fin >> f1;
// here def matrix A....

	matrix sA=A;
	{
	  {
	    ofstream ff("A.matrix");
	    ff << sA; 
	  }
	  matrix ssA;
	  {
	    ifstream ff("A.matrix");
	    ff >> ssA;
	    ssA = (1.)*sA+ (-1.)*ssA;
	    cout << ssA << endl; 
	  }
	}

```
