Skip to content

Instantly share code, notes, and snippets.

@sbchisholm
Created January 9, 2015 13:42
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 sbchisholm/7e59e579853cc5e1b03d to your computer and use it in GitHub Desktop.
Save sbchisholm/7e59e579853cc5e1b03d to your computer and use it in GitHub Desktop.
#include<fstream>
#include<iostream>
int main(int argc, char* argv[]) {
std::cout << "sizeof(unsigned int)" << sizeof(unsigned int) << std::endl;
std::cout << "sizeof(double)" << sizeof(double) << std::endl;
if (argc < 2) return -1;
std::ifstream stream;
std::cout << "file: " << argv[1] << std::endl;
stream.open(argv[1], std::ios::in);
unsigned int count;
stream.read((char*)&count, sizeof(count));
//stream >> count;
if (not stream.good()) return -1;
std::cout << "count: " << count << std::endl;
for (int i = 0; i < 10; ++i) {
double d;
stream.read((char*)&d, sizeof(d));
//stream >> count;
if (not stream.good()) return -1;
std::cout << d << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment