
已解决问题
谷歌染清尘用户在2013.12.17提交了关于“霍华德C程序 无法解析的外部符号”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-12-25T03:26:02。一**三个文件要求把12号文件放在一起编译我把三个文件放在一个文件夹然后打开a.c文件编译通过点Build时出现提示无法解析的外部符号(就是2号文件内的那几个)望指点!!!主要是不理解怎么把12号文件一起编译!
1.程序名a.c
#include<stdio.h>
#include"hotel.h"//定义常量、声明函数
intmain(void)
{
intnights;
doublehotel_rate;
intcode;
while((code=me**())!=QUIT)
{
switch(code)
{
case1:hotel_rate=h**OTEL1;
bre**;
case2:hotel_rate=h**OTEL1;
bre**;
case3:hotel_rate=h**OTEL1;
bre**;
case4:hotel_rate=h**OTEL1;
bre**;
default:hotel_rate=0.0;
printf("oops!\n");
bre**;
}
nights=getnights();
showprice(hotel_rate,nights);
}
printf("thankyouandgoodbye.");
return0;
}
2.程序名hotel.c
//9.9程序支持模块
#include<stdio.h>
#include"hotel.h"
intme**(void)
{
intcode,status;
printf("\n%s%s\n",STARS,STARS);
printf("Enterthe**mberofthedesiredhotel:\n");
printf("1)fairfieldarms2)hotelolympic\n"
"3)chertworthyplaza4)thestockton\n"
"5)退出");
printf("%s%s\n",STARS,STARS);
while((status=scanf("%d",&code))!=1||(code<1||code>5))
{
if(status!=1)
scanf("%*s");
printf("Enteranintegerfrom1to5,please.\n");
}
returncode;
}
intgetnights(void)
{
intnights;
printf("howmanynightsareneeded?");
while(scanf("%d",&nights)!=1)
{
scanf("%*s");
printf("Pleaseenteranintegersuchas2.\n");
}
returnnights;
}
voidshowprice(doublerate,intnights)
{
intn;
doubletotal=0.0;
doublefactor=1.0;
for(n=1;n<=nights;n++,factor*=DISCOUNT)
total+=rate*factor;
printf("thetotalcostwillbe$%0.2f.\n",total);
}
3.程序名hotel.h
//旅馆程序中的常量定义和函数声明
#defineQUIT5
#defineh**OTEL180.00
#defineh**OTEL2125.00
#defineh**OTEL3155.00
#defineh**OTEL4200.00
#defineDISCOUNT0.95
#defineSTARS"*************************************"
//给出选项列表
intme**(void);
//返回预定的天数
intgetnights(void);
//按饭店的星级和预定的天数计算价格并显示出来
voidshowprice(double,int);希望大家能够帮助她。
详细问题描述及疑问:一**三个文件要求把12号文件放在一起编译我把三个文件放在一个文件夹
然后打开a.c文件编译通过点Build时出现提示无法解析的外部符号(就是2号文件内的那几个)望指点!!!主要是不理解怎么把12号文件一起编译!
1.程序名a.c
#include<stdio.h>
#include"hotel.h"//定义常量、声明函数
intmain(void)
{
intnights;
doublehotel_rate;
intcode;
while((code=me**())!=QUIT)
{
switch(code)
{
case1:hotel_rate=h**OTEL1;
bre**;
case2:hotel_rate=h**OTEL1;
bre**;
case3:hotel_rate=h**OTEL1;
bre**;
case4:hotel_rate=h**OTEL1;
bre**;
default:hotel_rate=0.0;
printf("oops!\n");
bre**;
}
nights=getnights();
showprice(hotel_rate,nights);
}
printf("thankyouandgoodbye.");
return0;
}
2.程序名hotel.c
//9.9程序支持模块
#include<stdio.h>
#include"hotel.h"
intme**(void)
{
intcode,status;
printf("\n%s%s\n",STARS,STARS);
printf("Enterthe**mberofthedesiredhotel:\n");
printf("1)fairfieldarms2)hotelolympic\n"
"3)chertworthyplaza4)thestockton\n"
"5)退出");
printf("%s%s\n",STARS,STARS);
while((status=scanf("%d",&code))!=1||(code<1||code>5))
{
if(status!=1)
scanf("%*s");
printf("Enteranintegerfrom1to5,please.\n");
}
returncode;
}
intgetnights(void)
{
intnights;
printf("howmanynightsareneeded?");
while(scanf("%d",&nights)!=1)
{
scanf("%*s");
printf("Pleaseenteranintegersuchas2.\n");
}
returnnights;
}
voidshowprice(doublerate,intnights)
{
intn;
doubletotal=0.0;
doublefactor=1.0;
for(n=1;n<=nights;n++,factor*=DISCOUNT)
total+=rate*factor;
printf("thetotalcostwillbe$%0.2f.\n",total);
}
3.程序名hotel.h
//旅馆程序中的常量定义和函数声明
#defineQUIT5
#defineh**OTEL180.00
#defineh**OTEL2125.00
#defineh**OTEL3155.00
#defineh**OTEL4200.00
#defineDISCOUNT0.95
#defineSTARS"*************************************"
//给出选项列表
intme**(void);
//返回预定的天数
intgetnights(void);
//按饭店的星级和预定的天数计算价格并显示出来
voidshowprice(double,int);期待您的答案,谢了,下次有事儿别忘了找我
!