How can shorten this code
Sep 7, 2014 at 4:59pm UTC
How can shorten this code
I need to save 8739 blocks.
as shorten ofstream and classes.
as is a repeat, certain units read, you need to read
8739 blocks and save it,
here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
class bufferx
{
public :
char buffer[ 1081 ];
};
int main()
{
bufferx me;
me.buffer[ 1081 ];
bufferx a;
a.buffer[ 1081 ];
char letter;
ifstream file( "read.txt" );
while (!file.eof())
{
fill_n( me.buffer, 1081, '\0' );
file.read( me.buffer, 1080 );
string s( me.buffer );
ofstream binaryeik("block.txt" ,ios::out);
{
binaryeik<<me.buffer;
}
binaryeik.close();
fill_n( a.buffer, 1081, '\0' );
file.read( a.buffer, 1080 );
string si( me.buffer );
ofstream binaryeiki("block2.txt" ,ios::out);
{
binaryeiki<<a.buffer;
}
binaryeiki.close();
a:
ifstream binaryeikig("prodolziti.txt" ,ios::out);
letter = binaryeikig.get();
if (letter=='*' ) ;
else
goto a;
}
file.close();
return 0;
}
Last edited on Sep 7, 2014 at 5:00pm UTC
Sep 10, 2014 at 6:48pm UTC
You can remove line 1 and 3 and save 300k bytes in the exe.
Topic archived. No new replies allowed.