inline unsigned char *LoadChar(size_t beginpoint, long length, FILE *fp)
{
unsigned char *data = new (unsigned char[length]);
fseek(fp, beginpoint, SEEK_SET);
for (int i = 0; i < length; i++)
{
unsigned char read;
fread(&read, sizeof(char), 1, fp);
data<i> = read;
}
return data;
}
I have only one problem with it. It returns a whole bunch of ascii from a text section of a Binary. Anyone know how change the format of the data on the return to text, hex or decimal?
Strange File Returns
First off I would like to thank everyone who helped me develope this code. Here''s the code,
------------------------------------------------------------I wrote the best video game ever, then I woke up...
the for loop can be replaced with:
fread(data, length, 1, fp);
to do what you are saying you use a type cast. it already returns text. You can''t change the format to hex or decimal, it is forever binary. number systems only matter if you are printing a number, or writing an immediate number constant in code.
fread(data, length, 1, fp);
to do what you are saying you use a type cast. it already returns text. You can''t change the format to hex or decimal, it is forever binary. number systems only matter if you are printing a number, or writing an immediate number constant in code.
cmaker- I do not make clones.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement