Created
May 1, 2018 11:49
-
-
Save buxtonpaul/4ffb5bf4d7b21c46699c023e4e5d517f to your computer and use it in GitHub Desktop.
Quick function to read a binary file into a vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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