gpt4 book ai didi

c - 警告 : control reaches end of non-void function In User-Defined Function

转载 作者:太空宇宙 更新时间:2023-11-04 03:47:19 25 4
gpt4 key购买 nike

<分区>

恐怕这很可能只是一个很好的老式遗漏角色,但我很难过。还有其他人要找括号吗? :) 我使用以下函数在标题中得到编译器错误。帮助?提前致谢!

int print(char* cmd2, int sockfd)
{
int cmdNum;
int n;
int numR;
int i;

SREC* record;

if(strcmp(cmd2, "lname") == 0)
{
cmdNum = 1;
}
else if(strcmp(cmd2, "fname") == 0)
{
cmdNum = 2;
}
else if(strcmp(cmd2, "SID") == 0)
{
cmdNum = 3;
}
else if(strcmp(cmd2, "GPA") == 0)
{
cmdNum = 4;
}
else
{
printf("Unrecognized list: %s\n\n", cmd2);
return 1;
}

/*send cmdNum to server*/
n = write(sockfd, &cmdNum, sizeof(int));
if (n < 0)
{
printf("ERROR writing to socket/n");
}

/*recieve numR from server*/
n = read(sockfd, &numR, 255);
if (n < 0)
{
printf("ERROR reading from socket\n");
}

printf("| SID | Lname | Fname | M | GPA |\n+-------+-----------+------------+---+------+");

for(i = 0; i < numR; i++)
{
/*send i to server to tell it position of repetition*/
n = write(sockfd, &i, sizeof(int));

/*receive ith record*/
n = read(sockfd, record, sizeof(SREC));

/*print record to screen*/
printf("| %05lu | %9s | %9s | %c | %.2f |", record->SID, record->lname, record->fname, record->initial, record->GPA); }

printf("+-------+-----------+------------+---+------+\n");
}

return 0;
}

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