【求助】结构体作返回值
#include "math.h"#include "stdio.h"
struct cir_area
{
float l,s;};
struct cir_area c_area(float a,float b,float c)
{
struct cir_area result;
result.l=(a+b+c)/2;
reault.s=sqrt(reault.l*(result.l-a)*(result.l-b)*(result.l-c));
return result;
}
void main()
{
float a,b,c;
struct cir_aera triangle;
printf("输入三角形的3条边长: \n");
scanf("%f,%f,%f",&a,&b,&c);
triangle=c_area(a,b,c);
printf("半周长是: %f\n面积是: %f\n",triangle.l,triangle.s);
}
哪里错了,运行不了,书上例题,照打的
错误信息------Configuration: 23 - Win32 Debug--------------------
Compiling...
23.cpp
C:\Program Files\Microsoft Visual Studio\23\23.cpp(14) : error C2065: 'reault' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\23\23.cpp(14) : error C2228: left of '.s' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\23\23.cpp(14) : error C2228: left of '.l' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\23\23.cpp(20) : error C2079: 'triangle' uses undefined struct 'cir_aera'
C:\Program Files\Microsoft Visual Studio\23\23.cpp(24) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct cir_area' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\23\23.cpp(25) : error C2228: left of '.l' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\23\23.cpp(25) : error C2228: left of '.s' must have class/struct/union type
执行 cl.exe 时出错.
23.exe - 1 error(s), 0 warning(s)