Skip to content

Instantly share code, notes, and snippets.

@odan
Created January 3, 2024 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odan/95b71239842b69088b8a0b5abb45e4bd to your computer and use it in GitHub Desktop.
Save odan/95b71239842b69088b8a0b5abb45e4bd to your computer and use it in GitHub Desktop.

File Operations in C++

Reading a file into a string variable

#include <iostream>
#include <fstream>
using namespace std;

fstream file("file.name.xml", fstream::in);
string buffer;
string line;
while (getline(file, line)) {
    buffer = buffer + line;
}
file.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment