gpt4 book ai didi

c - 不确定我的编译错误 : control reaches end of non-void function

转载 作者:行者123 更新时间:2023-11-30 21:00:36 24 4
gpt4 key购买 nike

当我尝试将代码提交给我的教授时,我收到一条编译错误,并显示以下消息:

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;
}

最佳答案

您忘记从 getDbl返回任何内容。

关于c - 不确定我的编译错误 : control reaches end of non-void function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40325223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com