Google is full of C-ish answers. I'm looking for std::string way to accomplish this task
Google is full of C-ish answers. I'm looking for std::string way to accomplish this task
Google is full of C-ish answers.
Those answers will work in C++ as well. C++ doesn't have features that would make this easier... yet 1.
An overview of options that are available:
objcopy.xxd tool (from the vim editor) can be used to do this. This is portable, although there may be implementation specific limits to how large files can be included like this.It is also worth it to re-consider whether importing text file at compile time is even a good idea for your use case. Often, it is more useful to read the file at runtime because it allows the file to easily be changed without requiring re-compilation.
1 There is a proposal to add such feature to a future standard.