【发布时间】:2022-01-01 23:43:58
【问题描述】:
在我的一个结构中访问 char ** 时遇到问题。
uint64_t id;
struct timing timing;
//command *command;
uint32_t argc;
char ** argv;
} taskR;
我在我的结构中正确存储所有内容,但是当从文件中读取它时,我无法访问 argv 部分,但没有“核心转储”警报(其他参数工作得很好)
taskR stp;
uint64_t ip=stp.id;
read(i,&stp,sizeof(struct task));
struct timing ti;
ti=stp.timing;//all good
printf("%s",stp.argv[0]);//core dumped
大家新年快乐 :) 回答问题!!
【问题讨论】:
-
这个问题的答案可能会对你有所帮助:stackoverflow.com/q/2763438
-
请阅读How to create a Minimal, Reproducible Example 并编辑您的问题,以提供格式正确的所有声明和定义,以我们可以编译和测试的方式,就像您的sn-ps代码一样,我们无法做到语法检查等等。谢谢
标签: arrays c pointers struct coredump