Check the function
array_count:
1. if the buffer is unsigned char,
2. if the buffer is char all value,
because a binary file has 0 so often in the function get_srring.
Here is the function fread in C.
fread ( g_dummy, 1, num, structure_fp.fp );
1.g_dummy is a (char*) buffer.
2.memory_allocation is a (unsigned char*)buffer.
In the case of 1, we can not read the binary file well.
We have to know only the case of 3 like the below.
3. g_dummy = (char*) memory_allocation ;
//https://qiita.com/satken2/items/d14b4113fe3fb5f5597b //https://en.wikipedia.org/wiki/MPEG-4_Part_14 int read_mp4_004 (char* filename ) { FILE *fp; char b_dummy[256]; int i, j ; int file_end; STRUCT_FILE structure_fp; char c; char* p_dummy = NULL; char* p_dummy_token = NULL; int canread; char* block_string; int b_index = 0; char w_filename[255]; int index = 0; int col = 0; char* typeofkey[3] = { "ftyp", "mdat", "moovt" }; int m = 0; printf("int read_mp4 (char* filename ) starts.\r\n"); fp = fopen(filename, "rb"); structure_fp.file_start = fp; structure_fp.fp = fp; file_end = filesize(fp); structure_fp.file_end_index = file_end; canread = 1; int ini = initialize_parse (); // Lootn check if we set 100 to the text file. fread ( memory_allocation, 1, 4, structure_fp.fp ); for ( i=0; i<4; i++ ) { printf("i:%04d unsigend char %04d\r\n", i, memory_allocation[i] ); } p_dummy = (char*)memory_allocation; for ( i=0; i<4; i++ ) { printf("i:%04d char %04d\r\n", i, p_dummy[i] ); } fclose ( structure_fp.fp ); // aFree ( p_dummy_token ); printf("int read_mp4 (char* filename ) ends.\r\n"); return 0; }
> .\winmain_001.exe .\SANY6907.MP4
argc[i] filename = .\SANY6907.MP4
int read_mp4 (char* filename ) starts.
int initialize_parse () starts.
int initialize_parse () ends.
i:0000 unsigend char 0000
i:0001 unsigend char 0000
i:0002 unsigend char 0000
i:0003 unsigend char 0024
i:0000 char 0000
i:0001 char 0000
i:0002 char 0000
i:0003 char 0024
int read_mp4 (char* filename ) ends.
void print_memories () starts.
void print_memories () ends.