I am having the following problem reading a binary in C.
I read the first 8 bytes of the binary. Now I need to start reading from the 9th byte. Below is the code:
fseek(inputFile, 2*sizeof(int), SEEK_SET);
However, when I print the contents of the array, where I store the received values, it still shows me the first 8 bytes that I do not need.
Can anyone help me with this?
fseekjust moves the file stream position indicator; once you have moved the position indicator, you need to call freadto actually read the bytes from the file.
fseek
fread
, fread, ( , , , ). fread, . fseek, .
, :
FILE* file = fopen(FILENAME, "rb"); char buf[8];
8 , 8 :
/* Read first 8 bytes */ fread(buf, 1, 8, file); /* Read next 8 bytes */ fread(buf, 1, 8, file);
8 fseek 8 (8.. 15 , 0):
/* Skip first 8 bytes */ fseek(file, 8, SEEK_SET); /* Read next 8 bytes */ fread(buf, 1, 8, file);
, C . fread , , fread . fseek .
P.S.: . ( 1 fread)
Source: https://habr.com/ru/post/1739561/More articles:keybd_event does not work correctly = (- c ++forloop and table in LaTeX - for-loopΠΠ°ΠΊ ΡΠ΅Π°Π»ΠΈΠ·ΠΎΠ²Π°ΡΡ Π±Π»ΠΎΠΊΠΈΡΠΎΠ²ΠΊΡ Π·Π°ΠΏΡΠΎΡΠ°-ΠΎΡΠ²Π΅ΡΠ° Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΏΡΠΈΠΌΠΈΡΠΈΠ²ΠΎΠ² Java concurrency? - javaLinux SMP kernel barriers - linux-kernellogback per-logger configuration not working - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1739562/typical-svn-repo-structure-seems-to-be-sub-optimal-for-continuous-integration&usg=ALkJrhi6JesZqMMJpZsQ2bYub0VJ1GrKxAΠΡΡΡΠΈΠΉ ΡΠΏΠΎΡΠΎΠ± Π½Π°ΠΉΡΠΈ ΠΏΠΎΡ ΠΎΠΆΠΈΠ΅ ΠΎΠ±ΡΠ΅ΠΊΡΡ Π² python - pythonphp, but with a new constructor ... maybe? - phpMouse scaling in WinForms? - c #Game platforms for Java game cards - javaAll Articles