获取此错误:之后的第一个括号之前的int main
。不知道为什么!做一个介绍性编程课程的作业。所以任何帮助,将不胜感激!获取错误:期望的标识符或'('在'{'标记之前
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
{
int main(void);
int cardNum(int firstCard, int secondCard;
int highLow;
int score;
score = 0;
srand(time(NULL));
printf("The current card is a %d\n" ,firstCard(2,14));
printf("\n Will the next card be higher(1) or lower(2)? (press 0 to quit)");
scanf("%d" ,highLow);
if cardNum > 1 && cardNum < 11
{
printf ("The card is: %d ,secondCard.");
}
else if cardNum == 11
{
if highLow == 1, && secondCard > firstCard OR highLow == 2, && secondCard < firstCard
{
score = score + 1;
printf ("\n You have guessed correctly.");
printf ("\n Your current score is %d ,score!\n");
printf("The current card is a ("%d" ,cardOne). \n Will the next card be higher(1) or lower(2)? (press 0 to quit)");
}
else if highLow == 1, && secondCard < firstCard OR highLow == 2, && secondCard > firstCard
{
score = score - 1;
printf ("The card is: %d ,secondCard.");
printf ("\n You have guessed incorrectly.");
printf ("\n Your current score is %d ,score!\n");
printf ("The current card is a %d ,cardOne.");
printf ("\n Will the next card be higher(1) or lower(2)? (press 0 to quit)");
}
else if secondCard == firstCard
{
printf ("\n Matching cards, no change in score");
}
else if highLow == 0
{
printf ("\n Thanks for playing! Your final score is %d, score.");
}
else
{
printf ("\n Incorrect input. Please enter 0, 1 or 2")
}
}
return(0);
}
我最初有这样说,这与诠释主要(无效){但后来我得到所有这些错误,而不是,所以我把它改成分号,只得到了一个错误。
a3.c:函数'main'中: a3.c:24:5:错误:期望的声明说明符或'...'之前'score' a3.c:25:5:错误:预期声明说明符或's'在'srand'之前 a3.c:27:5:错误:预期声明说明符或'...'在'printf'之前' a3.c:28:5:错误:预期声明说明符或'...'在'printf'之前 a3.c:29:5:错误:预期声明说明符或'...'在'scanf'之前 a3.c:31:5:错误:预期声明说明符或'...'在'if'之前 a3.c:82:1:错误:预期声明说明符或'...'在'}'令牌之前 a3在'}'标记之前,'.c:82:1:error:expected';',','或')' a3.c:82:1:错误:预期声明或输入结束时的语句 a3.c: 82:1:警告:控制达到非无效功能的结束[ -Wreturn型]
删除;在'int main(void)'之后' – DoxyLover
int main(void); ===> int main(void){ – Gangadhar
也'如果cardNum> 1 && cardNum <11'应该是'if(cardNum> 1 && cardNum <11)' – karthikr