我需要从文件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);
你能告诉我们什么行给你编译错误吗? – JaredPar
你的意思是说“PrintCity();”而不是“void PrintCity();”? –
@JaredPar在文件Dist.C中,与void PrintCity();一致和AddOnEnd(); – user3161483