" Every time I run the executable, I get the statement that says the files weren't opened.
That's probably because you run it with a different current directory than the file opening statements assume.
Unfortunately there is no guaranteed standard library way to obtain the executable's own directory. However, with the C++17 filesystem library you can form a complete path from (the main
function's) argv[0]
, and drop the last item of that path. In most cases that will get you the executable's directory, and then you can form absolute paths for the support files.
" Is there a way I can include these files when I am making it an executable file?
Many.
Different OS-es provide different APIs for such resources (data embedded in executable), which one might be tempted to use. Unfortunately there's no abstraction over that in the standard library. That means it's not easily portable.
Since your files are all text files you can however simply embed them as string literals in your code.
One simple way for a header file is like this:
#pragma once
inline auto my_text()
-> char const*
{
char const* const s = R"unique-id(
blah
blah blah
blah blah blah
)unique-id";
return s + 1;
}