我已经编写了一个程序,它将在scanf两次之前printf输出两个应该是单个的程序printf.该问题似乎从要求用户输入1到4之间的数字以查看输入的天数的平均温度开始.
我不确定是什么导致这种双输入和输出以及偶尔的延迟.这是我的代码:
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int i;
int limit;
int day[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int high[10], low[10];
printf("---===IPC Temperature Analyzer V2.0===---\n");
printf("Please enter the number of days between 3 and 10, inclusive: ");
scanf("%d", &limit);
while (limit <= 2 || limit >= 11) {
printf("Invalid entry, please enter a number between 3 and 10, inclusive: ");
scanf("%d", &limit);
} …Run Code Online (Sandbox Code Playgroud) 我正在编写一个函数getIntLimited,它只能在某个最大值和最小值之间的数字之外.目前没有指定的最大值或最小值,但代码应该基本上起作用.但是,我似乎得到一个错误,说我在函数中的参数太少,但我不确定为什么会这样.这是我的代码:
#include <stdio.h>
#include <stdlib.h>
//tools
void welcome(void);
void printTitle(void);
void printFooter(double gTotal);
void flushKeyboard(void);
void pause(void);
int getInt(void);
double getDouble(void);
int getIntLimited(int lowerLimit, int upperLimit);
//app interface
int yes(void);
void GroceryInventorySystem(void);
int menu(void);
int main(void){
int iVal;
double dVal;
welcome();
printTitle();
double grandtotal = 1234.57;
printFooter(grandtotal);
flushKeyboard();
pause();
getInt();
int lowLimit;
int upLimit;
getIntLimited(int lowLimit, int upLimit);
return 0;
}
//code your functions here:
void welcome(void)
{
printf("---=== Grocery Inventory System ===---");
printf("\n");
return;
}
void printTitle(void)
{
printf("Row …Run Code Online (Sandbox Code Playgroud)