Why are you using dynamic allocation for buf1 and buf2? Why two buffers anyway?
In line 5+6 you cast integers to pointers. That makes no sense.
In line 7+8 you write the first byte of each of said pointers, which also makes no sense.
You probably meant this:
1 2 3 4 5 6 7
unsignedchar buf[2];
for (int i=0;i<Size;i++)
{
buf[0]=Bin[i]/256;
buf[1]=Bin[i]&255;
FileWrite(iDATAHandle2,buf,2);
}
I used two buffers because i need to swap bytes sometimes (producing files for Win and for unix).
But your method does the same and much easier!
Thanks again! It works!