Skipping Bytes When Reading Files
-
Hi! I have this sort of set up in my code: FILE *gen; int i; gen = fopen("data\\gen.dat", "r"); fscanf(gen, "%c", &i); Now at this point in the code the next couple of bytes are useless. How do I skip them out? I could run fscanf a couple of times but Im positive this is not the best solution. Thanks!
-
Hi! I have this sort of set up in my code: FILE *gen; int i; gen = fopen("data\\gen.dat", "r"); fscanf(gen, "%c", &i); Now at this point in the code the next couple of bytes are useless. How do I skip them out? I could run fscanf a couple of times but Im positive this is not the best solution. Thanks!
fseek
-
Hi! I have this sort of set up in my code: FILE *gen; int i; gen = fopen("data\\gen.dat", "r"); fscanf(gen, "%c", &i); Now at this point in the code the next couple of bytes are useless. How do I skip them out? I could run fscanf a couple of times but Im positive this is not the best solution. Thanks!
use seek or fseek - Shailesh
-
Hi! I have this sort of set up in my code: FILE *gen; int i; gen = fopen("data\\gen.dat", "r"); fscanf(gen, "%c", &i); Now at this point in the code the next couple of bytes are useless. How do I skip them out? I could run fscanf a couple of times but Im positive this is not the best solution. Thanks!
If it's just a couple of bytes, there is nothing wrong with using an additional
fscanf()
. Just read the bytes into a variable named something likeextra
orfluff
.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen