Initial commit

This commit is contained in:
Michael Reber
2019-11-15 12:59:38 +01:00
parent 40a414d210
commit b880c3ccde
6814 changed files with 379441 additions and 0 deletions
@@ -0,0 +1,27 @@
Another example of read() and write() and illustrates the use of gcount( )
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
double doubleNumberArray[4] = {99.75, -34.4, 1776.0, 200.1};
int i;
ofstream out("numbers", ios::out | ios::binary);
if(!out) {
cout << "Cannot open file.";
return 1;
}
out.write((char *) &doubleNumberArray, sizeof doubleNumberArray);
out.close();
for(i=0; i<4; i++) // clear array
doubleNumberArray[i] = 0.0;
ifstream in("numbers", ios::in | ios::binary);
in.read((char *) &doubleNumberArray, sizeof doubleNumberArray);
cout << in.gcount() << " bytes read\n"; // see how many bytes have been read
for(i=0; i<4; i++) // show values read from file
cout << doubleNumberArray[i] << " ";
in.close();
return 0;
}