# String Formatting for TEXT

**URL:** <https://forums.unrealengine.com/t/string-formatting-for-text/290626>\
**Category:** UI\
**Tags:** string, text, fobjectfinder, unreal-engine, CPP, question\
**Created:** [August 10, 2014, 9:37pm UTC](https://forums.unrealengine.com/t/string-formatting-for-text/290626 "2014-08-10T21:37:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErayT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ErayT](https://forums.unrealengine.com/u/ErayT)\
**Post date:** [August 10, 2014, 9:37pm UTC](https://forums.unrealengine.com/t/string-formatting-for-text/290626/1 "2014-08-10T21:37:42Z")

</div>

What I want to do is easy but I cannot figure it out.

```
static ConstructorHelpers::FObjectFinder<UStaticMesh> GroundShape(TEXT("StaticMesh'/Game/Shapes/Ground/ground_shape_1.ground_shape_1'"));

```

The code above is the think I want to achieve. However, it is going to be a dynamic version of it. For instance rather than ground\_shape\_1, I want the number 1 to be non-static. I want version like ground\_shape\_1, ground\_shape\_2, ground\_shape\_3 and so on. However, I do not know how to format a TEXT.

```
FString::Printf(TEXT("StaticMesh'/Game/Shapes/Ground/ground_shape_%d.ground_shape_%d'"), i);   

```

The code above looks fine but FObjectFinder just does not want FString but TChar only.

Any Suggestions?

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [August 10, 2014, 9:40pm UTC](https://forums.unrealengine.com/t/string-formatting-for-text/290626/2 "2014-08-10T21:40:14Z")

</div>

The dereference operator (\*) is overloaded on FString to return a pointer to its internal TCHAR buffer.

This should sort you out:

```
*FString::Printf(TEXT("StaticMesh'/Game/Shapes/Ground/ground_shape_%d.ground_shape_%d'"), i);

```

---

<div class="post-metadata">

**Author:** ![ErayT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ErayT](https://forums.unrealengine.com/u/ErayT)\
**Post date:** [August 10, 2014, 9:48pm UTC](https://forums.unrealengine.com/t/string-formatting-for-text/290626/3 "2014-08-10T21:48:31Z")

</div>

Thank you sir. I need to improve my C++ skills.

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [August 10, 2014, 9:51pm UTC](https://forums.unrealengine.com/t/string-formatting-for-text/290626/4 "2014-08-10T21:51:43Z")

</div>

Oh, that one’s a Unreal Engine oddity 🙂

I’ve never seen another string class that does that (you usually either have to call a function to get the buffer, or they overload the cast operator to allow it to happen implicitly).
