# Problem reading text file

**URL:** <https://root-forum.cern.ch/t/problem-reading-text-file/36972>\
**Category:** Newbie\
**Created:** [November 27, 2019, 12:07am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972 "2019-11-27T00:07:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@Abh](https://root-forum.cern.ch/u/Abh)\
**Post date:** [November 27, 2019, 12:07am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/1 "2019-11-27T00:07:02Z")

</div>

Hello  
I have started writing codes. And facing problems somewhere. Here i want to read the text file that i have generated and to plot some histograms. I have followed some examples from internet. Here I only can create the root file but not the histograms. I have attached the text file and my C file.Can someone please guide me.

---

<div class="post-metadata">

**Author:** ![pamputt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pamputt/32/12526_2.png) [@pamputt](https://root-forum.cern.ch/u/pamputt)\
**Post date:** [November 27, 2019, 6:50am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/2 "2019-11-27T06:50:39Z")

</div>

Try to add

```auto
h1->Write();
h2->Write();
h3->Write();

```

before closing `f`.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 27, 2019, 7:14am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/3 "2019-11-27T07:14:13Z")

</div>

```cpp
  // ...
  TString s;
  while (1)
    {
      in >> s >> s >> s >> px >> s >> s >> s >> py >> s >> s >> s >> pz;
      // ...

```

---

<div class="post-metadata">

**Author:** ![Abh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@Abh](https://root-forum.cern.ch/u/Abh)\
**Post date:** [November 27, 2019, 11:13am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/4 "2019-11-27T11:13:22Z")

</div>

Nope. Nothing happened.  
Thanks for the response.

---

<div class="post-metadata">

**Author:** ![Abh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@Abh](https://root-forum.cern.ch/u/Abh)\
**Post date:** [November 27, 2019, 11:14am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/5 "2019-11-27T11:14:05Z")

</div>

yeah but I can’t get all the values for px,py and pz.  
Thank you for the response.

---

<div class="post-metadata">

**Author:** ![OSchaile](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/e495f1/32.png) [@OSchaile](https://root-forum.cern.ch/u/OSchaile)\
**Post date:** [November 27, 2019, 11:51am UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/6 "2019-11-27T11:51:26Z")

</div>

whats the problem with Wiles mod?  
att your hist pz vs py, all 10000 are in:  
[C\_Fhist\_pz\_py\_v4.pdf](https://root-forum.cern.ch/uploads/short-url/nzdxinbL07MIptL4CR5b779OAib.pdf) (16.3 KB)  
Why do you start nlines = 100? but thats irrelevant  
Otto

---

<div class="post-metadata">

**Author:** ![Abh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@Abh](https://root-forum.cern.ch/u/Abh)\
**Post date:** [November 27, 2019, 1:23pm UTC](https://root-forum.cern.ch/t/problem-reading-text-file/36972/7 "2019-11-27T13:23:25Z")

</div>

Yeah. That was the mistake. I got it. Thank you. 🙂
