【问题标题】:In my eclipse C++ ide, why can't string related functions be resolved?在我的eclipse C++ ide中,为什么不能解析字符串相关的函数?
【发布时间】:2016-05-16 04:28:34
【问题描述】:

我有这段代码:

#include <iostream>
#include <string>

int main() {
    std::cout << "!!!Hello World " << std::endl;
    std::string a = "aa";
    std::string b;
    b = "bb";
    std::string c = strcat(a,b);
    std::cout << c << std::endl;
    return 0;
}

问题是“函数'strcat'无法解析”。另外,strcpystrlen 等其他关于字符串操作的函数也无法解析。既然我已经这样做了

#include <string>

我不知道为什么会这样?

【问题讨论】:

  • 那些函数属于&lt;cstring&gt;
  • 不要使用std::endl,除非你需要它的额外功能。 '\n' 开始新的一行。

标签: c++ eclipse string ubuntu


【解决方案1】:

strcat 是一个适用于char* 的 C 函数。你需要#include &lt;string.h&gt;

无论如何,您所做的都是错误的:您没有将std:string 参数传递给strcat

使用c = a + b;

【讨论】:

    猜你喜欢
    • 2013-06-09
    • 2015-03-20
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 2012-06-11
    • 2020-10-18
    相关资源
    最近更新 更多