Please find the code sample
void createFile(const std::string& FileName, const std::string& Content)
const std::string testFile = "/etc/testFile";
const std::string EmptyContent = "";
There's nothing extra that you can add to this program to "make it work". If an arbitrary program can write to
/etc, this would toss the traditional POSIX security model out the window.
In order to be able to write to
/etc, your program must be executed as root.