strlen 未在此范围内声明 - C++

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4564850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 15:45:44  来源:igfitidea点击:

strlen was not declared in this scope - C++

c++ubuntu

提问by Vivek

I need to install a simulator in my ubuntu. It is written in C++ and when I try to run make, I get this error strlen was not declared in this scope. Any solution to overcome this error?

我需要在我的 ubuntu 中安装一个模拟器。它是用 C++ 编写的,当我尝试运行 make 时,出现此错误strlen was not declared in this scope。有什么解决方案可以克服这个错误?

回答by icecrime

This should do it :

这应该这样做:

#include <cstring>

回答by dan04

#include <cstring>

Your program may also be looking for ::strleninstead of std::strlen. If this is the case, try

您的程序也可能正在寻找::strlen而不是std::strlen. 如果是这种情况,请尝试

using std::strlen;

回答by Spike

did you install all packages you needed?

你安装了你需要的所有软件包吗?

  1. try g++ --version and see if it gives something.
  2. check /usr/lib/include/ for string.h.
  1. 试试 g++ --version 看看它是否给出了一些东西。
  2. 检查 /usr/lib/include/ 中的 string.h。

If those things are not there, you need to check if the correct package is installed or not.

如果这些东西不存在,您需要检查是否安装了正确的软件包。