I need to check the download files for the game I am creating and I am having problems with it:
I just need to know if the first character is int in some range, if the next one is unsigned short int (checking the type and value of each character), and I could not find a function for this.
Also, I need to check if the nth character is the last character in the file (return an error code if it is not).
The file is binary.
How can i solve this?
Thanks!
E:
This is my boot file function:
Cod_Error load(Info * gameInfo) { FILE * loadFile; unsigned short int dif; int i; randomizeSeed(); gameInfo ->undo = FALSE; loadFile = fopen(gameInfo->fileArchivo, "rb"); fread(&dif, sizeof(dif), 1, loadFile); gameInfo->size = sizeFromDif(dif); gameInfo->undoPossible = FALSE; gameInfo->board = newBoard(gameInfo->size); if(gameInfo->board == NULL) return ERROR_MEM; fread(&(gameInfo->score), sizeof(Score), 1, loadFile); fread(&(gameInfo->undos), sizeof(unsigned short int), 1, loadFile); for(i = 0; i < gameInfo->size; i++) fread(gameInfo->board[i], sizeof(Tile), gameInfo->size, loadFile); fclose(loadFile); return OK; }
source share