c - 没有重载函数的实例与参数列表匹配
问题描述
错误:
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
and 可能会阻止你进一步混淆。
推荐阅读
- xml-parsing - 通过 concordion excel 扩展创建 HTML 文档时出现 XML 解析错误
- python - concurrent.futures.ThreadPoolExecutor :KeyboardInterrupt 不会触发 Windows 10 上的应用程序退出
- node.js - 使用反向代理 Nginx 的 Socket.io Socket.onPacket 错误
- java - Java Garbage Collector 会干扰 HPA 的缩减吗?
- swift - 如何在 Swift UIKit 的 if 语句中显示多个警报?
- python - 使用 HTCondor 的 DEAP 替代方案进行多处理
- react-native - 你可以在 flatlist 中多次使用自定义的原生 UI 组件和不同的数据吗?
- c++ - 时间测量的结束时间变量有什么意义吗?
- c++ - 是否有一个合理的场景,其中 == 运算符不是 != 的否定
- javascript - 过滤多个数组并将它们中的对象添加到单个数组中