英文程序源码编译-如何使用Dev-c++编译多个源代码文件

本文向您介绍如何使用Dev-c++编译多源代码文件。 主要包括如何使用Dev-c++编译多源代码文件的实例、应用方法、基础知识点总结以及注意事项。 具有一定的参考价值英文程序源码编译,有需要的同学可以参考。

1.在Dev-c++中创建一个空白项目

1.创建一个新项目

英文程序源码编译-如何使用Dev-c++编译多个源代码文件

2、创建一个空白工程,勾选c语言英文程序源码编译,并创建名称

3.在项目下创建子文件

4、C语言程序的文件后缀为.c,头文件的文件后缀为.h

2.多源代码编译

1.主要函数a文件

2. 在一个文件或多个文件中定义函数

3. 1个头文件(将声明的函数原型和固定常量放在1个头文件中)

4、引用c标准库中的头文件,用“ ”来引用自己定义的头文件。

英文程序源码编译-如何使用Dev-c++编译多个源代码文件

例子:

//主函数的编写
#include
#include "head_files.h"

int main(void)
{
int nights;
double hotel_rate;
int code;

while ((code=menu())!=QUIT)
{
switch (code)
{
case 1:hotel_rate=HOTEL1;
break;
case 2:hotel_rate=HOTEL2;
break;
case 3:hotel_rate=HOTEL3;
break;
case 4:hotel_rate=HOTEL4;
break;
}
nights=getnight();
showprice(nights,hotel_rate);
}
printf("Thank you and goog bye!n");
return 0;
}

//定义函数内容
#include
#include "head_files.h"
int menu(void)
{
int code;
int return_value;//定义了一个返回值变量
printf("Enter the number of desired hotel :n");
printf("(1) Fairfield Arms (2) Hotel Olympicn");
printf("(3) Chertworthy Pleaza (4) The Stocktonn");
printf("(5) Quitn");

while ((return_value=scanf("%d",&code))!=1||code>5||code<1)
{
if (return_value!=1)//注意,输入一个非数字,scanf()会有返回值,但是不会读取,因此要清空输入缓存流。
{
int ch;
while ((ch=getchar())!='n')
{
continue;
}
printf("Please input a number!n");
}
if (code>5||code<1)
{
printf("Please input a number from 1-5!n");
}
}
return code;
}

int getnight(void)
{
int nights;
int return_value;
printf("Please input the nights you want to live:n");
while ((return_value=scanf("%d",&nights))!=1||nights<0)
{
if (return_value!=1)//注意,输入一个非数字,scanf()会有返回值,但是不会读取,因此要清空输入缓存流。
{
int ch;
while ((ch=getchar())!='n')
{
continue;
}
printf("Please input a number!n");
}
if (nights<0)
{
printf("Please input a number bigger than 0!n");
}
}
return nights;
}


void showprice (int night,double hotel_rate)
{
double total;
int n;
double factor;
for (total=1.0,n=1,factor=1.0;n<=night;n++,factor*=DISCOUNT)
{
total+=hotel_rate*factor;
}
printf("You want to stay %d nights,and the total costs are:%fn",night,total);
return;
}

//定义头文件
#define HOTEL1 100
#define HOTEL2 150
#define HOTEL3 200
#define HOTEL4 300
#define DISCOUNT 0.95
#define QUIT 5
int menu(void);
int getnight(void);
void showprice(int, double);

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悟空资源网 源码编译 英文程序源码编译-如何使用Dev-c++编译多个源代码文件 https://www.wkzy.net/game/193454.html

常见问题

相关文章

官方客服团队

为您解决烦忧 - 24小时在线 专业服务