# Easy way to convert an int to a string?

**URL:** <https://root-forum.cern.ch/t/easy-way-to-convert-an-int-to-a-string/47503>\
**Category:** Newbie\
**Created:** [November 2, 2021, 1:39pm UTC](https://root-forum.cern.ch/t/easy-way-to-convert-an-int-to-a-string/47503 "2021-11-02T13:39:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzriu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@mzriu](https://root-forum.cern.ch/u/mzriu)\
**Post date:** [November 2, 2021, 1:39pm UTC](https://root-forum.cern.ch/t/easy-way-to-convert-an-int-to-a-string/47503/1 "2021-11-02T13:39:44Z")

</div>

Hi,

I would like to know if there are any easy ways to convert an Int\_t into a TString or a string in ROOT ?

In my case :

```auto
for(Int_t i = 1; i <= 84; i++) {
		h[i] = (TH1F*)f->Get("h"+TString(i));
		}

```

I would like to convert my i variable in the “for” loop into a string so that I can get the histogram called “h”+string(67) → “h67” for example.

Thanks for reading me !

---

<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 2, 2021, 1:41pm UTC](https://root-forum.cern.ch/t/easy-way-to-convert-an-int-to-a-string/47503/2 "2021-11-02T13:41:29Z")

</div>

`...->Get(TString::Format("h%d", i));`

---

<div class="post-metadata">

**Author:** ![mzriu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@mzriu](https://root-forum.cern.ch/u/mzriu)\
**Post date:** [November 2, 2021, 1:44pm UTC](https://root-forum.cern.ch/t/easy-way-to-convert-an-int-to-a-string/47503/3 "2021-11-02T13:44:41Z")

</div>

Works nicely ! Thanks for your response ! 😉
