我担心这很可能只是一个老式的错过角色,但我很难过。还有其他人为括号打猎吗? :)我使用以下函数在标题中得到编译器错误。救命?提前谢谢!
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;
}
答案 0 :(得分:1)
在你的行中:
printf("| %05lu | %9s | %9s | %c | %.2f |", record->SID, record->lname, record->fname, record->initial, record->GPA); }
最后有一个}
。一直向右滚动。