Integer file write and read.

 
int file_handleb=FileOpen("buy",FILE_READ|FILE_WRITE|FILE_BIN|FILE_COMMON);


FileWriteInteger(file_handleb,1,INT_VALUE);

int a = FileReadInteger(file_handleb,INT_VALUE);
Comment(a);
Why the output of FileReadInteger is zero? How to fix it?
 
persy5:
Why the output of FileReadInteger is zero? How to fix it?
Because you read at the end of the file. Use FileTell and FileSeek.
Documentation on MQL5: File Functions / FileTell
Documentation on MQL5: File Functions / FileTell
  • www.mql5.com
File Functions / FileTell - Documentation on MQL5
 
I add this line
FileSeek(file_handle,0,SEEK_SET);
and it works. Thanks  a lot!
Reason: