2013-10-18 4 views
0

이 오류를 얻으려면 : 앞에 #include 뒤에 expected identifier or ‘(’ before ‘{’ token 첫 번째 괄호에 그래서 어떤 도움을 주시면 감사하겠습니다!오류가 발생했습니다 : 예상 식별자 또는 '('앞에 '{'토큰이 있음

#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 주 (무효)와 그런 식으로했다가 {그러나 나는 단지 세미콜론으로 변경하고 대신 있도록 모든 오류를 얻고 있었다 것은 하나 오류가 발생했습니다.
a3.c : 'main'함수에서 : a3.c : 24 : 5 : 오류 : 예상 선언자 또는 '...'앞에 오류가 있습니다. 'score' a3.c : 25 : 5 : 오류 : 예상 선언자 또는 '...'before 'srand' a3.c : 27 : 5 : 오류 : 예상되는 선언 지정자 또는 'printf'앞에 '...' 'a3.c : 28 : 5 : 오류 :'printf '앞에 예상 선언자 또는'... '이 있습니다. a3.c : 29 : 5 : 오류 :'scanf '앞에 예상 선언자 또는'... '이 있습니다. a3.c : 31 : 5 : 오류 : 예상 선언 지정자 또는 '...'앞에 '...'가 삽입됩니다. a3.c : 82 : 1 : 오류 : 예상 선언 지정자 또는 '}'토큰 앞에 '...'가 삽입되었습니다. a3 .c : 82 : 1 : 오류 : '' '토큰 앞에'; ',', '또는') 예상 됨 a3.c : 82 : 1 : 오류 : 예상치 못한 선언이나 문장이 입력 끝 부분에 있음 a3.c : 82 : 1 : 경고 : 컨트롤이 비 - 보이드 함수의 끝에 도달 함 [ -Wreturn 형]

+1

; 'int main (void) '뒤에. – DoxyLover

+1

{ int main (void); ===> int main (void) { – Gangadhar

+0

또한 if cardNum> 1 && cardNum <11'은 if (cardNum> 1 && cardNum <11)이어야합니다. – karthikr

답변

7
{ 
int main(void); 

이 ...

int main(void) 
{ 

그럼 난 당신이 프로그램의 다음 컴파일 오류를 수정하도록해야

당신이 main 후 여는 중괄호를 배치해야
4

, 그 전에 아니야

#include <stdio.h> 
#include <stdlib.h> 
#include <time.h> 

int main(void) 
{ 
+0

'main' 다음에 세미 콜론이 있어서는 안됩니다. – Kunal

+0

죄송합니다 @Kunal이 그것을 삭제하는 것을 잊었습니다. –

관련 문제