CODE
#include <stdio.h>
int main()
{
int i;
int j;
FILE *fptr;
fptr = fopen("C:\\Users\\BOO\\Projects\\integer.bin","wb");
i=0x1234;
j=0x12345678;
putw(i,fptr);
putw(j,fptr);
fclose(fptr);
return 0;
}
int main()
{
int i;
int j;
FILE *fptr;
fptr = fopen("C:\\Users\\BOO\\Projects\\integer.bin","wb");
i=0x1234;
j=0x12345678;
putw(i,fptr);
putw(j,fptr);
fclose(fptr);
return 0;
}
I use format-hex cmd-let in PowerShell to hexdump the 8-byte "integer.bin".
The results is quite awkward, for 0x1234, it is " 34 12 00 00", but for 0x12345678, the "34 12" is not on the left-hand size, it is becoming as "78 56 34 12"..... No wonder I pening, pening kepala

Can someone know explain? Are you also new to this?
By the way, there is no way to save integer to file in Python, either text or byte mode only, means have to convert number to string then save to file, in Python.
May 24 2023, 08:07 AM, updated 3y ago
Quote





0.0210sec
0.41
5 queries
GZIP Disabled