Tell me what is the error in my code? The ReadFile function returns false. If you comment out the line "num = num * 10 + ((const char) lengthStrFile [i] - '0');" then the reading is normal. what is the problem?
HANDLE FileHandle = CreateFile((LPCWSTR)TEXT("file.txt"), GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); char * lengthStrFile; DWORD bytesRead; bool isOk ; int num = 0; int j; isOk = ReadFile(FileHandle, lengthStrFile, sizeof(char) * 8, &bytesRead, NULL); for (int i = 0; i < 8; i++){ if (lengthStrFile[i] == '$'){ for (j = 0; j < i;j++){ num = num * 10 + ((const char)lengthStrFile[i] - '0'); } break; } }