void RecvFile()
{
int rval;
char buf[0x1000];
FILE *file = fopen("C:\\pic.bmp", "wb");
if (!file)
{
printf("Can't open file for writing");
return;
}
do
{
rval = recv(winsock, buf, sizeof(buf), 0);
if (rval < 0)
{
// if the socket is non-blocking, then check
// the socket error for WSAEWOULDBLOCK/EAGAIN
// (depending on platform) and if true then
// use select() to wait for a small period of
// time to see if the socket becomes readable
// again before failing the transfer...
printf("Can't read from socket");
fclose(file);
return;
}
if (rval == 0)
break; //line 159
int off = 0;
do
{
int written = fwrite(&buf[off], 1, rval - off, file);
if (written < 1)
{
printf("Can't write to file");
fclose(file);
return;
}
off += written;
}
while (off < rval)
} //line 175
fclose(file);
}
'}' 标记之前的 175 语法错误
159 被早期错误混淆,退出
我不知道该怎么办...你能帮帮我吗?我在 c 编程方面还是个新手。我在代码中插入了错误行。我不明白为什么会出现这个错误......你们能解释一下为什么吗?