gpt4 book ai didi

c - 为什么我的两个计算函数都会出现 Unresolved external 系统错误(错误 LNK2019)?

转载 作者:行者123 更新时间:2023-11-30 19:13:33 26 4
gpt4 key购买 nike

为什么我的两个计算函数都会出现 Unresolved external 系统错误(错误 LNK2019)?错误 6 错误 LNK2019:无法解析的外部符号 _CalculateAreaRec错误7错误LNK2019:引用了无法解析的外部符号_CalcCircleArea错误 8 错误 LNK1120:2 个无法解析的外部

#include <math.h> 
#include <stdio.h>
#define PI 3.14159
#define _CRT_SECURE_NO_WARNINGS //to avoid scanf warning or error
/* Function prototype */
int CalculateAreaRec(int length, int width);
double CalcCircleArea(double radius);
int GetInt(void);
int main(void)
{
//Declared varibles
double radius;
int length;
int width;
int GetInt(void);
{
// this function gets an integer from the user and returns it
// this function is called 3 times from main

//Prompt for the radius of the circle.
printf("Whats the radius of the circle \n");
//Get the radius from the keyboard.
scanf("%lf", &radius);
//Display the radius and area of the circle onto the screen.
printf(" The radius is %lf and the area is %.4f \n", radius, CalcCircleArea(radius));
//Prompt for the length of a side
printf("Whats the length of a side of rectangle \n");
//Get the length from the keyboard
scanf("%d", &length, CalculateAreaRec(length, width));
//Prompt for the width of a side
printf("Whats length of the width \n");
//Get the width from the keyboard
scanf(" %d", &width, CalculateAreaRec(length, width));
//Display the side length, width, and area of the rectangle onto the screen.
printf(" The side length is %d the width is %d and the area of the rectangle is %d \n ", length, width, CalculateAreaRec);
}
double CalcCircleArea(double radius);
{
//Calculate the area of the circle (use 3.14).
return (PI * radius * radius);
}
int CalculateAreaRec(int length, int width);
//takes two arguments (base and height of the triangle) and returns the area
{
return (length*width);
//takes one argument (radius of the circle) and returns the area
}
}

最佳答案

C 不支持嵌套函数。他们都必须生活在最高层,彼此独立。

除此之外,您的 main 中似乎没有任何代码来调用其他函数。

您还错误地调用了 CalculateAreaRec。它不应该是 scanf 的参数,并且您需要在将其作为 printf 的参数调用时为其提供参数。

关于c - 为什么我的两个计算函数都会出现 Unresolved external 系统错误(错误 LNK2019)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35376007/

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