我正在尝试从文件中读取字节,但大小已损坏。调试时可以看到 的值st.st_size
,但看不到 的值size
。
int main(void)
{
FILE* oud;
struct stat st;
_off_t size;
unsigned* bytes;
char const path[] = "C:\\Users\\Ruben\\Documents\\test.txt";
errno_t error;
if ((error = fopen_s(&oud, path, "rb" )) != NULL)
return -1;
stat(path, &st);
size = st.st_size;
bytes = (unsigned*)malloc(size);
fread(bytes, 1, size, oud);
fclose(oud);
getchar();
return 0;
}