gpt4 book ai didi

c - 为什么我的代码无法运行?指针?

转载 作者:行者123 更新时间:2023-11-30 18:20:28 25 4
gpt4 key购买 nike

当我按 F7 时,我的代码成功编译并且“成功”,但当我通过 F5 构建时不会执行(“失败”)。我收到致命的 LNK1120 错误。我将其构建为控制台应用程序并使用了 cpp就像我对我编写的前 10 个程序所做的那样(第一周编程,我正在使用我的机构提供的免费 C++ Visual Studio 编译器)

这是代码,它应该教授模块化编程和指针。该程序应该接受一个数字,并告诉您它的符号、整数部分和小数部分。

#include<stdio.h>
#include<math.h>
void separate(float num, char *signp, int *wholep, float *fracp);
int main(void)
{
float value;
char sign;
int whole;
float fraction;

printf("Please enter a value to evaluate\n");
scanf("%f",&value);

separate(value, &sign, &whole, &fraction);

printf("The sign of your number is %c\n",sign);
printf("The whole part in your number is %d\n",whole);
printf("The fractional part in your number is %.4f\n",fraction);

return(0);
}
void seperate(float num, char *signp, int *wholep, float *fracp)
{
float magnitude;

if(num<0)
*signp = '-';
if(num==0)
*signp = ' ';
if(num>0)
*signp = '+';

magnitude=fabs(num);

*wholep = floor(magnitude);
*fracp = num-*wholep;
}

最佳答案

您的函数声明和定义中的 separateseparate 之间存在拼写错误。

关于c - 为什么我的代码无法运行?指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20794319/

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