你可以使用vector作为:
std::ifstream file("file.txt");
std::istreambuf_iterator<char> begin(file), end;
std::vector<char> v(begin, end); //it reads the entire file into v
char *contentOfTheFile= &v[0];
Run Code Online (Sandbox Code Playgroud)
文件的内容存储在contentOfTheFile.您可以使用它,也可以修改它.