visual c++ - store fread() in char instead memory buffer -
im new in c++ , i've noob questions:
i've trying program read iso file , return info size, block size, blocks...
my fist question fread, , how store readed info char variable instead buffer, because if store in buffer when return string program show text 4 'ý' characters.
if use example:
char *systemid = (char*) malloc(sizeof(char)*32); fread(systemid, 1, 8, infile); then works 4 'ý' @ end, if use:
systemid = (char*) malloc(sizeof(char)*32); fread(systemid, 1, 8, infile); then program crash...
how can store fread info char variable?, or how can avoid last 'ý' charactes?
another question i've: have info iso image , how list of files inside iso in c++. want without run programs, because 7zip , others can list of files want standalone program.
thanks in advance ;)
remember strings in c (and c++) needs terminated. fread function returns number of items read, , can use index terminate string:
char *systemid = malloc(32); size_t nread = fread(systemid, 1, 8, infile); if (nread > 0) systemid[nread] = '\0'; /* terminate string */ else { /* handle end-of-file or error */ }
Comments
Post a Comment