草庐IT

res_length

全部标签

c++ - std::string 的 strlen(str.c_str()) 和 str.length() 之间的区别

作为一种隐含的理解,我一直认为std::string的每一个实现必然必须满足strlen(str.c_str())==str.length()对于每个字符串str。C++标准对此有何规定?(是吗?)背景:至少VisualC++和gcc附带的实现没有这个属性。考虑这个例子(参见hereforaliveexample)://Output://stringsaysitslengthis:13//strlensays:5#include#include#includeintmain(){std::stringstr="Hello,world!";str[5]=0;std::cout当然,没有注

c# - 为什么 Array.Length 是一个 int,而不是一个 uint

这个问题在这里已经有了答案:Whydoes.NETuseintinsteadofuintincertainclasses?(7个答案)关闭9年前。为什么Array.Length是int,而不是uint。这让我很困扰(有点),因为长度值永远不会是负数。这也迫使我在自己的类中使用int作为长度属性,因为当你指定一个int值,这需要显式转换...所以最终的问题是:unsignedint(uint)有什么用吗?甚至微软似乎也不使用它们。

c++ - STL String::length() 段错误

#include#include#include/*UsingSTL'sstringclassbecausetheproblemdoesnotreferanylimitsregardingthenumberofcharactersperline.*/usingnamespacestd;intmain(){stringline;vectorlines;while(getline(cin,line)){lines.push_back(line);}unsignedinti,u;unsignedintopening=1;//2iflastwasopening,1ifitwasclosingf

c++ - 错误 : Variable length array of Non-POD element type 'string'

在开始之前,我必须首先声明,我已经研究过针对此错误的可能解决方案。不幸的是,它们都与不使用数组有关,这是我项目的要求。另外,我目前正在学习CS入门类(class),所以我的经验几乎没有。数组的用途是从文件中收集名称。因此,为了初始化数组,我计算了名称的数量并将其用作大小。问题是标题中所述的错误,但我仍然使用一维数组时看不到解决方法。主要.cpp#include#include#include#include#include#include"HomeworkGradeAnalysis.h"usingnamespacestd;intmain(){ifstreaminfile;ofstrea

c++ - 在抛出 'std::length_error' 实例后调用终止

这是我在这里的第一篇文章。由于我是新手,这个问题可能很愚蠢。当显示以下错误消息时,我正在编写一段代码,在抛出“std::length_error”的实例后调用终止什么():basic_string::_S_create/home/gcj/finals/home/gcj/quals中止的地方以下是有问题的代码,尤其是第39行到第52行。这对我来说很奇怪,因为这段代码几乎与第64行到第79行相同。intmain(){std::vectordirs,need;std::stringtmp_str;std::ifstreamfp_in("small.in");std::ofstreamfp_o

c++ - 将已编译的 .res 文件与 CMake 链接

我正在尝试将已编译的.res文件与cmake链接,但我似乎无法找到有关如何执行此操作的太多信息。我得到的最接近的是SET(RESOURCE_FILEresource.res)file(GLOBsrc_files"src/*.h""src/*.cpp""${RESOURCE_FILE}")add_executable(exename${src_files})然后通过IDE手动链接.res文件(即在visualstudio中将.res文件放入链接器附加依赖项中)。这意味着我每次更改cmake文件时都必须重置附加依赖项。当然有比这更好的方法请原谅我对cmake的经验不足,我们将不胜感激。

nodejs:加载html带有res.write()

我是NodeNode的新手,所以我正在尝试学习它。我正在尝试将简单的HTML文件加载到节点中,但这给了我错误,因为我使用时未定义HTMLres.write(html)我看到了一些与我相似的例子,所以我想了解这里出了什么问题。我写了:consthttp=require('http');constfs=require('fs');consthostname='127.0.0.1';constport=3000;fs.readFile('./index.html',(err,html)=>{if(err){throwerr;}});constserver=http.createServer((req

adb.exe:端口被占用 failed to check server version: protocol fault (couldn‘t read status): connection res

adb用着用着不行了。。然后使用命令行adbdevices就报错。解决方案也很简单。杀死占用5037的程序。然后重启adb先使用adbdevices看下是否报错adbdevices 报错后执行netstat-aon|findstr5307会找到一个进程。针对这个进程可以看下是什么程序tasklist|findstr13440一看是chrome.exe的进程,那么也很简单第一种命令行杀死进程taskkill/pid13440/f第二种Ctrl+Shift +Esc呼出任务管理器杀死chrome即可最后一步重启adbadbstart-server治标不治本啊。下次还会被抢占端口。解决端口占用的方法

使用毕加索库时获取android.content.res.res.resources $ notfoundexception

我正在使用毕加索库更新个人资料图片。我要以下问题android.content.res.Resources$NotFoundException:Resource"com.adamas.selfiereporter:id/profile_picture"(7f100176)isnotaDrawable(colororpath):TypedValue{t=0x12/d=0x0a=2r=0x7f100176}这是毕加索对象Picasso.with(getContext()).load(profileImageUrl).placeholder(R.id.profile_picture).transfo

iphone - NSString "initWithBytesNoCopy:length:encoding:freeWhenDone:"可以修改输入 "bytes"吗?

-(id)initWithBytesNoCopy:(void*)byteslength:(NSUInteger)lengthencoding:(NSStringEncoding)encodingfreeWhenDone:(BOOL)flag"bytes"不是常量指针。这是否意味着该方法可能会修改“字节”? 最佳答案 您应该假设它可能会发生变异,因为那是签名并且没有其他文件可以否定它。所以我的回答是:这是因为SEL的签名不会/不能为NSMutableString更改它被声明为非常量。这里有一些NSString创建替代方案,它们建议在没