i added this lines to my code and i have this errors:
Error 18 error LNK2019: unresolved external symbol _error referenced in function _main
Error 17 error LNK2019: unresolved external symbol _bzero referenced in function _main
Error 19 error LNK1120: 2 unresolved externals
My code snippet is-
else if (strcmp(text, "004") == 0)
{
i = 0;
menuCheck = 1;
puts("Please enter your folder.");
gets(text);
strcpy(folder, COM_MSG);
strcat(folder, "004");
strcat(folder, text);
puts("Please enter your folder for saving.");
gets(fr_name);
if ((temp = send(sock, folder, sizeof(folder), 0)) == SOCKET_ERROR)
{
printf("Error sending connection request to the server, error code: %d\n", WSAGetLastError());
}
/* Receive File from Server */
printf("[Client] Receiveing file from Server and saving it as final.txt...");
FILE *fr = fopen(fr_name, "a");
if (fr == NULL)
printf("File %s Cannot be opened.\n", fr_name);
else
{
bzero(revbuf, 512);
int fr_block_sz = 0;
while ((fr_block_sz = recv(sock, revbuf, 512, 0)) > 0)
{
int write_sz = fwrite(revbuf, sizeof(char), fr_block_sz, fr);
if (write_sz < fr_block_sz)
{
error("File write failed.\n");
}
bzero(revbuf, 512);
if (fr_block_sz == 0 || fr_block_sz != 512)
{
break;
}
}
if (fr_block_sz < 0)
{
if (errno == EAGAIN)
{
printf("recv() timed out.\n");
}
else
{
fprintf(stderr, "recv() failed due to errno = %d\n", errno);
}
}
printf("Ok received from server!\n");
}
}
what to do? thank you ! nir :)
bzero is deprecated, documentation recommends using memset / ZeroMemory macro (assuming you're running on windows) instead.
As for error()
, can't find any documentation for this function but you can use this instead:
fputs("File write failed.\n", stderr);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.