I'm trying to write a program that takes a file, and reads bytes from it in different intervals, and assigns them to a variable. This is what I currently have:
struct casc_file_parsed {
unsigned int targetsize;
uint64_t blocksize;
uint64_t blockcount;
csc_block_t* blocks;
};
struct casc_file_parsed parsed_casc_file;
FILE* fpc = fopen(casc_file_data, "r");
char c;
char str[MAX];
int i = 0;
int j = 0;
for(i = 0; i >= 24; i++) {
if(i >= 16 && i <= 24) {
str[j] = c;
j++;
}
c = fgetc(fp);
}
parsed_casc_file.targetsize = str;
I haven't tested it yet, since I know it isn't complete yet, and other functionalities needs to be added before it can run. What I am trying to do in this approach is creating a loop, and if I is the interval of 16-24, it saves the current byte to an array str. The array then needs to be transformed into an int, and saved in the struct (I am aware that the bottom line won't work). I'm not sure if this is the best approach, but I could really use some input right now, if there is a better way or I am missing anything.
EDIT: The .cascade file is a 64-byte file, containing a list of hashes describing another file. The 16-24 bytes in this file, contains the file length of the original file, as an unsigned integer in network byte order.