正如其他人所指出的,您没有提供任何解释
请求非结构或联合的成员
例如,在您的代码中,我们没有看到任何地方定义的缓冲区......无论如何:
蛮力方法:(按 ANSI C 编译、构建和运行)
#include <ansi_c.h>
#define newBinaryFile "C:\\tempExtract\\newbinaryfile.bin"
int main(void)
{
FILE *fp;
int i;
char clientDataNew[5][128] = {"","","","",""};
char clientdata[5][128] = { "This string is 128 bytes longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg1\n",
"This string is 128 bytes longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg2\n",
"This string is 128 bytes longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg3\n",
"This string is 128 bytes longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg4\n",
"This string is 128 bytes longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg5\n"};
fp = fopen (newBinaryFile, "wb");
fwrite(clientdata, sizeof(char), sizeof(clientdata), fp);
// for(i=0;i<5;i++)
// {
// fputs(clientdata[i], fp);
// }
fclose (fp);
fopen(newBinaryFile, "rb");
fread(clientDataNew, sizeof(char),sizeof(clientdata),fp);
for(i=0;i<5;i++)
{
(fgets (clientDataNew[i], 128, fp));
}
fclose(fp);
for(i=0;i<5;i++)
{
printf("%s", clientDataNew[i]);
}
getchar();
return 0;
}