pointers - 在 C 中初始化特定成员
问题描述
我想定义结构
#include <stdio.h>
#include <stdint.h>
#include <time.h>
//#include "templog.h"
#define DATE_SIZE 5
typedef struct {
int id;
int year;
int month;
int mday;
float min_temp, max_temp;
} tempValue_t
数据是
tempValue_t temps[DATE_SIZE] =
{ 0, { .tm_year = 2015, .tm_mon = 0, .tm_mday = 1 }, 19.26, 20.76 },
我收到了消息
error field name not in record or union initializer
解决方案
最后发现结构成员可以初始化,嵌套结构也可以用(.)初始化。
推荐阅读
- java - 更改 firebase 兄弟值
- git - 如何在 git /macbook 中将 VScode 设置为核心编辑器
- javascript - 为什么在变量名前加冒号是js中的有效代码?
- python - 如何通过迭代另一个工作表来创建工作表的副本,同时排除数组中的某些行。?
- pandas - 散景 - ValueError:关键字参数序列
- azure - Azure 云服务(经典)- 以任何方式将 Diagnostic.Trace 日志记录到 BLOB 存储
- python - Keras LSTM 输入 ValueError: Input 0 is in compatible with layer lstm_1: expected ndim=3, found ndim=4
- c# - 我可以将 Visual Studio 2017 连接到免费的 000webhost MySql 数据库吗?
- css - 如何将网站从 Zurb Foundation 4 迁移到 Zurb Foundation 6?
- flutter - Flutter_bloc 从没有 UI 事件的 firestore 获取更新的数据