gpt4 book ai didi

编译错误,成员不是 union 体的成员 |使用指针/结构

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

我重写了一个项目所需的函数,用于构建包含媒体本身信息的媒体数据库。在下面的代码中,我尝试从用户那里获取标题长度格式为 HH:MM:SS 的字符串。然后,我必须使用指向第一个 isdigit 字符的指针分割字符串几个小时,第一个“:”之后的第一个 isdigit 字符分割几分钟,最后一个“:”之后的第一个 isdigit 字符来检查字符串是否符合我希望用户执行的操作进入。为了检查子字符串是否合法,我然后使用 atoi 转换为 int 并尝试写回到结构中,但指针正在为我干杯。任何帮助表示赞赏。

这是代码本身(pastebin以提高可读性)datetime.c with functions to examine string and put pointers on first digit of the input, first digit after first: and first digit after last:

我评论了编译错误发生的位置(pastebin 上的 l.103 105 107)

为了获得更好的见解,这里是我使用的结构:

datastructure.h everything but char * zeit is required as written

提前谢谢,我最近真的感觉很愚蠢,试图通过反复试验来强制它进行编译,而且我认为我根本没有接近目的地......

编辑:当我尝试编译时:

||=== Build: Debug in Iue2 (compiler: GNU GCC Compiler) ===|
C:\Users[...]\datetime.c||In function 'convertStringToTime':|
C:\Users[...]\datetime.c|104|error: request for member 'hour' in something not a structure or union|
C:\Users[...]\datetime.c|106|error: request for member 'minute' in something not a structure or union|
C:\Users[...]1\datetime.c|108|error: request for member 'second' in something not a structure or union|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

最佳答案

第 74 行已损坏:它必须是 void ConvertStringToTime(char * strTime , TTime * lp) 而不是 void ConvertStringToTime(char * strTime , TTime * Zeit) 。其他一切似乎都很好。现在将尝试完成内存分配,并将 strtol() 作为替代解决方案。

关于编译错误,成员不是 union 体的成员 |使用指针/结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27093926/

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