2014-01-05 4 views
0

DB.c 및 ListOfCity.c 파일에서 Dist.c 파일을 전환해야하지만 VS 2010에서 오류가 발생합니다 :
오류 C2143 : 구문 오류 : ';'이 (가) 없습니다. 전에 '유형'. (모든 경우에 온라인 상태)

프로젝트를 C++ (C 대신 C++가 필요함)로 컴파일하면 컴파일 된 exe 파일을 실행할 수 있지만 숫자 1 또는 2를 입력하면 " 계속하려면 열쇠. " 함수를 실행하지 마십시오. 미리 감사드립니다!다른 파일에서 함수 호출하기

파일 Dist.c

#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h> 
#include <stdlib.h> 
#include <crtdbg.h> 
#include "db.h" 

#define _CRTDBG_MAP_ALLOC 

int main(int argc, char** argv) { 
    int choice; 
    do { 
     printf("[1] Index of city\n[2] Add city to end some next\Your choice: "); 
     scanf("%d", &choice); 
     switch(choice){ 
      case 1: 
       void PrintCity(); 
     system("pause"); 
     break; 
      case 2: 
       AddOnEnd(); 
     system("pause"); 
     break; 

      ..... 

      default: 
       printf("Another numer.\n"); 
     system("pause"); 
     break; 

     break; 
     } 
    } while (volba != 0); 

파일 DB.h

#include "ListOfCity.h" 
typedef struct Database { 
    int numberOfCity; 
    tListOfCity* list; 
    double **distances; 
} tDatabase; 

tDatabase *LoadDatabase(char* file); 
void DeleteDatabase(tDatabase* db); 
int GiveIndexCity(tDatabase* db, char* city); 
double GiveDistanceBetweenCities(tDatabase* db ,char* city1, char* city2); 
double CountDistance(tDatabase* db, tListOfCity* list); 
void PrintDistance(tDatabaze* db, tListOfCity* list); 

귀하의 AddOnEnd() 선언이 개 매개 변수를 취

#define LENGTH 60 

typedef struct ListOfCity { 
    char city[LENGTH]; 
    struct ListOfCity* next; 
} tListOfCity; 

tListOfCity* CreateCity(char* city); 
tListOfCity *AddOnEnd(tListOfCity* list, tListOfCity* new); 
void PrintCity(tListOfCity* list); 
+0

컴파일 오류를 제공하는 행을 표시 할 수 있습니까? – JaredPar

+2

"PrintCity();"라고 말하고 싶습니까? "void PrintCity();"대신 "? –

+0

Dist.C 파일의 @JaredPar, void PrintCity(); 및 AddOnEnd(); – user3161483

답변

2

파일 ListOfCity.h :

tListOfCity *AddOnEnd(tListOfCity* list, tListOfCity* new); 

하지만 함수 호출이 전달되지 않습니다 ???

AddOnEnd(); 

또한

,

void PrintCity(); 

은 함수를 호출하지 않는 함수를 선언합니다.

+0

그래야 씁니다 "AddOnEnd (tListOfCity * list, tListOfCity * new);" 대신에 "AddOnEnd();" 또는 어떻게? – user3161483

관련 문제