gpt4 book ai didi

c - 没有重载函数的实例与参数列表匹配

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

错误:

E0304   no instance of overloaded function "strstr" matches the argument 
list testtranslator
E0304 no instance of overloaded function "strstr" matches the argument
list testtranslator
E0167 argument of type "const char **" is incompatible with parameter of
type "const char *" testtranslator
C2665 'strstr': none of the 2 overloads could convert all the argument
types testtranslator
C2665 'strstr': none of the 2 overloads could convert all the argument
types testtranslator
C2664 'size_t strlen(const char *)': cannot convert argument 1 from 'const
char *[2]' to 'const char *'

我对编程很陌生,但我必须在后天编写这个英语-法语文本翻译器。它必须用给定的单词或短语替换这些单词...我的文本是以下“你好”、“什么”和“你好吗?”我需要把它翻译成“Salut”,“Comment vas-tu?”我不知道如何处理这些错误,我将非常感谢您的帮助。

提前谢谢您!

最佳答案

您正在尝试将 const char** 作为 word 参数传递,而我猜您的想法是传递 const char*。看起来您需要从 word 数组中选择特定单词,如下所示:

strstr(string, word[0])

因为您最近将其声明为:

const char *word[] = {
"hello",
"what"
};

顺便说一下,将 word 重命名为 words,这可能会阻止您进一步感到困惑。

关于c - 没有重载函数的实例与参数列表匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53915658/

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