Skip to content

Instantly share code, notes, and snippets.

@buxtonpaul
Created May 1, 2018 11:49
Show Gist options
  • Save buxtonpaul/4ffb5bf4d7b21c46699c023e4e5d517f to your computer and use it in GitHub Desktop.
Save buxtonpaul/4ffb5bf4d7b21c46699c023e4e5d517f to your computer and use it in GitHub Desktop.
Quick function to read a binary file into a vector
template <class T>
std::vector<T> readFile(const char *filename)
{
std::vector<T> results;
std::ifstream fin(filename, std::ios::binary);
T n;
while (fin.read(reinterpret_cast<char *>(&n), sizeof(T)))
results.push_back(n);
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment