gpt4 book ai didi

根据 C 中的条件更改指针(星号 1.4 cdr 结构)

转载 作者:太空宇宙 更新时间:2023-11-04 03:40:45 25 4
gpt4 key购买 nike

如何执行以下操作? full_agentstring 需要指向 cdr->channel 或 cdr->dstchannel:

....
char *cdr_channel = cdr->channel;
char *cdr_dstchannel = cdr->dstchannel;
char *full_agentstring = NULL;
if(strstr(cdr_channel, agent_pattern) != NULL) {
*full_agentstring = cdr->channel;
} else if(strstr(cdr_dstchannel, agent_pattern) != NULL) {
*full_agentstring = cdr->dstchannel;

我也尝试过 full_agentstring = &cdr_dstchannel 但仍然收到警告:

从不兼容的指针类型赋值[默认启用]

最佳答案

if(strstr(cdr_channel, agent_pattern) != NULL) {
full_agentstring = cdr->channel;
} else if(strstr(cdr_dstchannel, agent_pattern) != NULL) {
full_agentstring = cdr->dstchannel;

或者如果我没有正确理解你的问题,那么这是第二种方法

char *cdr_channel = cdr->channel;
char *cdr_dstchannel = cdr->dstchannel;
char **full_agentstring = NULL;
if(strstr(cdr_channel, agent_pattern) != NULL) {
full_agentstring = &cdr->channel;
} else if(strstr(cdr_dstchannel, agent_pattern) != NULL) {
full_agentstring = &cdr->dstchannel;

关于根据 C 中的条件更改指针(星号 1.4 cdr 结构),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28884878/

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