I have a file I am compiling in C++ in which I wish to have a string whose value is the contents of a file at the time of compilation.
In other words, I\'d like to #
An obvious (if somewhat naive) way is to make a system call and invoke cpp -x c++ file.cpp
, and then read the contents of the stream directly into a string just like you would any other file-read operation.
This invokes the C preprocessor on file.cpp
in C++ mode, which is exactly identical to running #include ...
on it. This value will then be stored in the string
object.