gpt4 book ai didi

c++ - visual C++ 声明一个字符串数组

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:25:59 27 4
gpt4 key购买 nike

我想使用非托管 C++。

以下代码:

#include"string.h"
std::string nodename[100];

给我以下编译错误:

'std' : is not a class or namespace name

最佳答案

您使用了错误的头文件。你应该是#include荷兰国际集团<string> , 不是 "string.h" :

  • <string>是定义 C++ STL 类的头文件 std::string
  • <string.h>是字符串函数的 C 标准库的头文件,它对 C 字符串进行操作 ( char * )
  • <cstring>是像<string.h>这样的头文件, 但它在 std 中声明了所有 C 字符串函数命名空间

对于像这样的系统头文件,你应该总是#include它们带有尖括号,而不是双引号。

关于c++ - visual C++ 声明一个字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1499815/

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