I'm very confused with this wee little problem I have. I have a non-indexed file format header. (more specifically the ID3 header) Now, this header stores a string or rather three bytes for conformation that the data is actually an ID3 tag (TAG
is the string btw.) Point is, now that this TAG
in the file format is not null-terminated. So there are two things that can be done:
- Load the entire file with
fread
and for non-terminated string comparison, usestrncmp
. But:- This sounds hacky
- What if someone opens it up and tries to manipulate the string w/o prior knowledge of this?
- The other option is that the file be loaded, but the C struct shouldn't exactly map to the file format, but include proper null-terminators, and then each member should be loaded using a unique call. But, this too feels hacky and is tedious.
Help, especially from people who have practical experience with dealing with such stuff, is appreciated.