gpt4 book ai didi

c - 存储为单独的变量 C 编程

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

嗨,我尝试将两个 get_input 方法存储为单独的变量,但我不确定如何存储。另外,我在主方法中的 get_input 一直说它隐式区分,请帮忙

#include <stdio.h>

double main()
{
get_input();
get_input();
}

double get_input(void)
{
double x1;
printf("Enter any number: ");
scanf("%lf", &x1);
return x1;
}

double get_next(double x2,double x1)
{
double total;
total=(((x2)/2)+3(x1));
return total;
}

void print_result()
{
return null;
}

最佳答案

您的编译器提示它不知道您的函数get_input。编译是从上到下完成的,所以当到达:

double main()
{
get_input();

您的编译器不知道 get_input 是什么。您需要在 main 之前声明(可选地定义)您的函数。

double get_input();
double main()
{
get_input();

这称为函数原型(prototype),即使 get_input 尚未定义,编译器至少知道它存在并可以继续编译。

您可能希望将 get_input 的返回分配给一个值以供以后使用:

double value = get_input();

关于c - 存储为单独的变量 C 编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35122358/

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