出现此错误:expected identifier or ‘(’ before ‘{’ token
在 . 之后的第一个括号#include
上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);
}
我最初用 int main(void){ 就这样,但后来我得到了所有这些错误,所以我把它改成了分号,只得到了一个错误。
a3.c:在函数'main'中:a3.c:24:5:错误:预期的声明说明符或'score'之前的'...' a3.c:25:5:错误:预期的声明说明符或'.. .' 在 '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: 错误:预期的声明说明符或 '...' 在 '}' 标记 a3 之前.c:82:1:错误:输入 a3.c:82:1 结尾处的预期声明或语句:警告:控制到达非 void 函数的结尾 [-Wreturn-type]