libc-start.c: No such file or directory after core dump
<p>So I have been working on a text-game in C++. It is a text-based building game. I have been able to solve every issue, and it is working fine until I got to this part. Currently I am working on loading and saving games to the storage device, but the program outputs "Segmentation fault (Core Dump)" at this part of the code:</p>

<pre><code>int loadGame(std::string path){
    std::ifstream exists(path.c_str());

    if(exists){
        std::cout &lt;&lt; "  File found, press any key to load . . . ";
        getch();
        std::cout &lt;&lt; std::endl;
    } else {
        std::cout &lt;&lt; "  Error: file not found, press any key to continue . . ." &lt;&lt; std::endl;
        getch();
        return 1;
    }
</code></pre>

<p>In case you're wondering, I am on linux, and have made my own "getch" function with:</p>

<pre><code>int getch(void){
    struct termios oldattr, newattr;
    int ch;

    tcgetattr(STDIN_FILENO, &amp;oldattr);

    newattr = oldattr;
    newattr.c_lflag &amp;= ~( ICANON | ECHO);

    tcsetattr(STDIN_FILENO, TCSANOW, &amp;newattr);

    ch = getchar();

    tcsetattr(STDIN_FILENO, TCSANOW, &amp;oldattr);

    return ch;
}
</code></pre>

<p>Currently I call the loadGame function with an:</p>

<pre><code>if(loadGame(readInputFile()) == 0)
</code></pre>

<p><code>readInputFile()</code> is a function that does a simple std::cin and returns it. I could go on and on with all the code...</p>

<p>However right after the "File found..." the program crashes with that error... The weirdest thing? getch() has worked for me the whole time, and when I put it before the std::cout "File found", and getch worked. I debugged this in Code Blocks (my IDE), and got the following information:</p>

<pre><code>Program received signal SIGSEGV, Segmentation fault.
In ?? () ()
287 libc-start.c: No such file or directory.
#2  0x00007ffff7216ec5 in __libc_start_main (main=0x4019d0, argc=1, argv=0x7fffffffe428, init=&lt;optimized out&gt;, fini=&lt;optimized out&gt;, rtld_fini=&lt;optimized out&gt;, stack_end=0x7fffffffe418) at libc-start.c:287
Debugger finished with status 0
</code></pre>