Read how to debug small programs and also the documentation of GDB (or of whatever debugger you have on your machine).
Compile your program (that is the C++ file, let's name it josh.cc
, shown in your question) with all warnings and debug info. I recommend to compile it on the command line with g++ -Wall -Wextra -g josh.cc -o joshprog
(read how to invoke GCC for details) then to debug it with gdb ./joshprog
and to run it in a terminal as ./joshprog
.
The point is that your IDE (Atom + XCode) is not helping you. It hides you important details (see this answer, it also works for MacOSX or other Unix systems). That is why I strongly recommend compiling (and running, and debugging) your code with explicit commands that you are typing in a terminal emulator for your shell and understanding (so read the documentation of every command that you are using). Once you are fluent with compilation on Unix systems, you might eventually switch to an IDE (but you need to understand what your IDE is doing on your behalf, and what commands it is running).
You could add into your code something displaying the current working directory by using getcwd (which requires #include <unistd.h>
on POSIX system), maybe something like
char mycwdbuf[80];
memset (mycwdbuf, 0, sizeof(mycwdbuf));
if (getcwd(mycwdbuf, sizeof(mycwdbuf)-1) != NULL)
std::cout << "current directory is " << mycwdbuf << std::endl;
By doing that, you'll probably understand how is your program started and in which working directory. I guess that it was not started in the working directory that you wanted it to.