# Save cells data in TXT file

**URL:** <https://community.freefem.org/t/save-cells-data-in-txt-file/129>\
**Category:** General Discussion\
**Created:** [September 7, 2019, 7:10pm UTC](https://community.freefem.org/t/save-cells-data-in-txt-file/129 "2019-09-07T19:10:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fffm\_84](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fffm\_84](https://community.freefem.org/u/fffm_84)\
**Post date:** [September 7, 2019, 7:10pm UTC](https://community.freefem.org/t/save-cells-data-in-txt-file/129/1 "2019-09-07T19:10:02Z")

</div>

Hello everybody,  
I tried to save cells data of a mesh, in a text file, with the code:

{  
ofstream file(“file.txt”);  
//file\<\<“CELLS”\<\<Th.nt\<\<" “\<\<4\*Th.nt\<\<endl;  
for (int i=0; i\<Th.nt; i++){  
for (int j=0; j\<3; j++){  
file\<\<Vh(i,j)\<\<” ";  
};  
file\<\<endl;  
};  
};

But saved data are different from saved data with savemesh(Th,“Th.txt”) code.  
What is wrong???  
Thank you all!!!

---

<div class="post-metadata">

**Author:** ![robin997](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@robin997](https://community.freefem.org/u/robin997)\
**Post date:** [September 8, 2019, 2:45am UTC](https://community.freefem.org/t/save-cells-data-in-txt-file/129/2 "2019-09-08T02:45:06Z")

</div>

@fffm_84 The _savemesh_ function saves the coordinates of the mesh, and _Vh(i,j)_ is showing the connectivities of the mesh. So they are different things. If you want to save the data (_fespace_), use the _ffmatlib.idp_. I added below my edited version with the load data function added.

[ffmatlib-Edited.idp](https://community.freefem.org/uploads/short-url/i39tAjwzGvu8H4yqYGabfaPPRhu.idp) (4.7 KB)

---

<div class="post-metadata">

**Author:** ![fffm\_84](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fffm\_84](https://community.freefem.org/u/fffm_84)\
**Post date:** [September 8, 2019, 12:30pm UTC](https://community.freefem.org/t/save-cells-data-in-txt-file/129/3 "2019-09-08T12:30:54Z")

</div>

Thank you!!!  
There is something I don’t understand:

- when I check the TRIANGLES lists (one made with savemesh command, and the other with the code above) they are different in the first/last two rows!
