2014-01-05 139 views
0

我需要從文件DB.c和ListOfCity.c切換文件Dist.c中調用函數,但VS 2010給我錯誤:
錯誤C2143:語法錯誤:缺少';'在「類型」之前。 (在任何情況下都行)

當我編譯項目爲C++(而不是C,但我需要C而不是C++)時,我可以運行編譯的exe文件,但是當我輸入數字1或2時,它只顯示「Press any關鍵是要繼續。「並且不要運行該功能。提前致謝!從另一個文件調用函數

文件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); 

文件ListOfCity.h

#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

@JaredPar在文件Dist.C中,與void PrintCity();一致和AddOnEnd(); – user3161483

回答

2

AddOnEnd()聲明有兩個參數:

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

但你的函數調用不通過任何?

AddOnEnd(); 

此外,

void PrintCity(); 

聲明的函數,它不調用一個函數。

+0

所以我應該寫它 「AddOnEnd(tListOfCity * list,tListOfCity * new);」 而不是 「AddOnEnd();」 還是如何? – user3161483

相關問題