gpt4 book ai didi

c - fread() 没有写入缓冲区

转载 作者:可可西里 更新时间:2023-11-01 13:50:43 26 4
gpt4 key购买 nike

#include <Windows.h> 
#include <stdio.h>

int count = 0;
FILE* pFile = 0;
long Size = 0;

void *memfrob(void * s, size_t n)
{
char *p = (char *) s;

while (n-- > 0)
*p++ ^= 42;
return s;
}

int main()
{
fopen_s(&pFile, "***", "r+");
fseek(pFile, 0, SEEK_END);
Size = ftell(pFile);
char *buffer = (char*)malloc(Size);
memset(buffer, 0, Size);
fread(buffer, Size, 1, pFile);
fclose(pFile);
memfrob(buffer, Size);
fopen_s(&pFile, "***", "w+");
fwrite(buffer, Size, 1, pFile);
fclose(pFile);
}

您好,fread 没有从文件读取任何内容到缓冲区,我不明白为什么。有人可以给我提示或插入正确的方向吗?

最佳答案

在你害怕之前,你需要回到文件的开头。

关于c - fread() 没有写入缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3744035/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com