Kibor Bot Autoclicker » Kibor - Integrated development environment for bots » About Kibor » Version 3.09 Finalization of reading and writing to a file. Work in binary mode

Страниц (1): [1]
 

1. Kibor - 24 Июля, 2018 - 03:27:28 - перейти к сообщению
The functions of reading and writing to a file have been improved.
See the description of working with files in Kibor: reading the entry in a text file

Implemented work with binary files.

To open a file in binary read mode, you need to call fopen with the "rb" key.
fopen ("D:\calc.exe","rb");

For reading in binary mode, the function freadb

Syntax:
char preiemnik_a [999999];
freadb (# preiemnik_a [0], 999999);

The first parameter is a pointer to a char array in which it will be read. The second number of bytes to read. If the file is smaller, read as much as the file has.
The return value is the number of bytes read. If the second parameter is larger than the file size, it returns the number of bytes equal to the file size.


To open a file in binary mode, you need to call fopen with the "wb" or "ab" key.

For writing fwriteb

Syntax:
fwriteb (# preiemnik_a [0], 122465);
The first parameter is a pointer to the char array, the one from which to write. The second number of bytes written bytes.

fwriteb (preiemnik_a [5]);
Accepted parameter is char;

Example of reading and writing with copying an exe file:
CODE:
char preiemnik_a [999999];
int g=0;
if (fopen ("D:\calc.exe", "rb")!=0)
{
g=freadb (#preiemnik_a [0], 999999);
fclose ();
}
messagebox (g);
g--;
int nn=0;
if (fopen ("D:\calc1.exe", "wb")!=0)
{
/ *
r: if (nn <g) // Write byte // Take time ..
{
fwriteb (preiemnik_a [nn]);
nn ++;
goto r;
}
* /
fwriteb (#preiemnik_a [0], g); // Write pointer to wild char

fclose ();
}


Example of reading a text file saved in Unicode
CODE:
char preiemnik [999999];
int g=0;
if (fopen ("C:\Russ text in Unicode.txt", "rb")!=0)
{
g=freadb (#preiemnik [0], 999999);
fclose ();
}

string T="";
int i;
for (int n=2; n <g-1; n=n + 2)
{
if (preiemnik [n] == 0) goto er;
i=codhexi (#preiemnik [n], 2) -848;
if (i == - 835) {T=T + formatic (13) + formatic (10); n=n + 2;}
else T=T + formatic (i);

}
er :;
messagebox (T);

Powered by ExBB FM 1.0 Final