作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
error: must use "struct" tag to refer to type 'point'
我想要做的就是将坐标存储为结构。这看起来简单得令人发狂,但在访问了 20 个网站并浏览了 Kernaghan 的书后我却做不到。
我错过了什么?
#include <stdio.h>
int main()
{
struct point
{
float x;
float y;
};
point.x = 0.0;
point.y = 1.9;
return 0;
}
最佳答案
您定义了一个名为struct point
的类型,而不是使用该定义的变量名称。您想要使用该类型定义结构的实例:
struct point mypoint; // In C, you could change mypoint to point, but that gets confusing
或者(不太常见)通过将名称放在结构定义之后、分号之前来声明具有(可能是匿名)结构定义类型的变量:
struct {
float x;
float y;
} point;
关于c - 如何在 C 中实现具有两个 float 的结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39215523/
我是一名优秀的程序员,十分优秀!