 <p>You're returning a pointer to a local array, which is destroyed when the function returns. The best solution is to return a string object:</p> <pre><code>std::string read_word() { std::string input; std::cin &gt;&gt; input; return input; } </code></pre> <p>Note that I also changed the function name to match what it does. If you actually want a line, then you want</p> <pre><code>std::string read_line() { std::string input; std::get_line(std::cin, input); return input; } </code></pre> <p>If you really think you want to return a pointer, then think again. You almost certainly don't.</p> <p>If you still really think you do, then you could return a pointer to a static variable, which lasts as long as the program:</p> <pre><code>// Danger: the returned pointer is only valid until the next call. // Danger: do not call from multiple threads. // Danger: any line longer than 255 characters will cause dreadful calamity. char const * read_line() { static char input[256]; std::cin.getline(input); return input; } </code></pre> <p>or dynamically allocate an array, and hope the caller remembers to delete it:</p> <pre><code>// Danger: the returned pointer must be deleted (with `delete[]`) after use // Danger: any line longer than 255 characters will cause dreadful calamity. char const * read_line() { char * input = new char[256]; std::cin.getline(input); return input; } </code></pre>