当我尝试提交我的代码我的教授,我得到一个编译错误,消息如下结束:不确定我的编译错误:控制到达非void函数
ipc_ms1.c: In function ‘getDbl’: ipc_ms1.c:146:1: warning: control reaches end of non-void function [-Wreturn-type] ipc_ms1.c: In function ‘getInt’: ipc_ms1.c:122:1: warning: control reaches end of non-void function [-Wreturn-type]
我不知道该怎么办
#include <stdio.h>
void welcome(void);
int getInt(void);
double getDbl(void);
void prnTitle(void);
void prnFooter(double gTotal);
void pause(void);
double getDblLimited(double lowerLimit, double upperLimit);
void welcome(void)
{
printf("---=== Grocery Inventory System ===---\n");
}
void prnTitle(void)
{
printf("Row |SKU| Name \t | Price |Taxed| Qty | Min | Total |Atn \n");
printf("----+---+--------------------+--------+-----+-----+-----+------------+|---\n");
}
void prnFooter(double gTotal)
{
printf("--------------------------------------------------------+----------- ------\n");
//float gTotal = 1234.57;
while (gTotal > 0)
{
printf("%12.21f", gTotal);
}
}
void clrKyb(void)
{
char b;
while (b != '\n')
{
scanf("%c", &b);
}
}
void pause(void)
{
printf("Press <Enter> to continue...");
clrKyb();
}
int getInt(void)
{
printf("Enter an interger:");
int d;
char c;
scanf("%d%c", &d, &c);
while (c != '\n')
{
printf("Invalid integer, please try again ");
scanf("%d%c", &d, &c);
}
}
int getIntLimited(int lowerLimit, int upperLimit)
{
int a;
printf("Enter an integer between %d and %d:", lowerLimit, upperLimit);
scanf("%d", &a);
while (a <= lowerLimit || a >= upperLimit)
{
printf("Invalid value, %d < value < %d:", lowerLimit, upperLimit);
scanf("%d", &a);
}
return a;
}
double getDbl(void)
{
double d;
char c;
printf("Enter a floating point number:");
scanf("%lf,%c", &d, &c);
while (c != '\n')
{
printf("Invalid number, please try again ");
scanf("%lf%c", &d, &c);
}
}
double getDblLimited(double lowerLimit, double upperLimit)
{
double a;
printf("Enter a floating point number between %f and %f:", lowerLimit, upperLimit);
scanf("%lf", &a);
while (a <= lowerLimit || a >= upperLimit)
{
printf("Invalid value, %f < value < %f:", lowerLimit, upperLimit);
scanf("%lf", &a);
}
return a;
return 0;
}
哪里的'main'函数? – artm
这是一个6部分的项目,对于这部分的提交,我们被告知不包括主要功能 – ortz3
请(doc-)正确评论和格式化您的源代码。不要编写和不提供未注释的代码_。思考为什么它不会抱怨'int getInt(void)'(或者是它呢?那么'double getDblLimited()'?)怎么样? (应避免使用'getType()'重复'scanf()'调用。) – greybeard