# How do i run a Console Command in C++

**URL:** <https://forums.unrealengine.com/t/how-do-i-run-a-console-command-in-c/317988>\
**Category:** C++\
**Tags:** console-command, unreal-engine, bug-report, CPP, question\
**Created:** [May 9, 2015, 12:06pm UTC](https://forums.unrealengine.com/t/how-do-i-run-a-console-command-in-c/317988 "2015-05-09T12:06:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Evols](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evols](https://forums.unrealengine.com/u/Evols)\
**Post date:** [May 9, 2015, 7:35pm UTC](https://forums.unrealengine.com/t/how-do-i-run-a-console-command-in-c/317988/2 "2015-05-09T19:35:41Z")

</div>

Exec() takes in parameter a const TCHAR\*. But, TEXT(SomeString) does not perform FString conversion to const TCHAR\*. To do this, you have to use the \* operator. So, try this instead:

```
GetWorld()->Exec(GetWorld(), *Final);

```

TEXT(“some text”) should only be used to make a const TCHAR\* for litterals (i.e. defining a string with quotes). Final is a FString, not a litteral. At a lower level, TEXT() adds a L before the litteral, to tell the compiler that the string is in wide char, as described in [this page](http://en.cppreference.com/w/cpp/language/string_literal). Example: TEXT(“UE4”) will become L"UE4".

---

_[View the full topic](https://forums.unrealengine.com/t/how-do-i-run-a-console-command-in-c/317988)._
