Alright, lets start with the first one then.
You never use anything from iomanip and there's no reason to, so remove it.
You're
using namespace std;
so
std ostream
in line 9 should just be
ostream
. If you weren't
using namespace std;
, it would be
std::ostream
.
You forgot the semicolon at the end of line 22. You should also be writing to writingFile, not cout. You made that same mistake on line 38.
Change line 32 to
for ( int x = 1; x < 6; ++x )
. You're off by one. It's a fairly common mistake.
cin.getline has to be passed two things: the location to store the data, and the amount of data to store. You have the first, the second should be the length of tempChar ( 100 ).
There's no reason to seekp within the loop. You could seekp(0) before the loop and it would work fine, but you said you wanted to try using these functions and your code isn't wrong so there's no need to remove it.
I have to go so I'll do this quick. Change binary_write to:
1 2 3 4 5
|
template<typename T>
ostream & binary_write ( ostream & stream, const T & value, int length )
{
return stream.write ( value, sizeof ( T ) * length );
}
|
and change the two lines that call it to
binary_write ( writingFile, tempChar, 100 );
.
That should be everything. I'll be back tomorrow.