gpt4 book ai didi

c - SQLite3 : Assigned directly the query result to a struct in C

转载 作者:太空宇宙 更新时间:2023-11-04 04:54:48 26 4
gpt4 key购买 nike

我在网上搜索但找不到解决我问题的方法。我有一个包含字段 user_id、用户名、密码的表 user_info。我还有一个结构 st_user_info。

typedef struct {
int userId;
char* userName;
char* password;
} T_USERINFO;
T_USERINFO tUserInfo[10];

现在,我希望将来自 sqlite3_step 命令或任何命令的查询结果直接分配给此结构 tUserInfo[index]。有没有办法在这条路上做......?谢谢。

最佳答案

不支持高级语言功能,例如 reflection在 C 中,所以简短的回答是否定的。 SQLite 无法自动为您填充结构。您必须以正常方式检索查询结果,并自行将值分配给结构。

关于c - SQLite3 : Assigned directly the query result to a struct in C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10189810/

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