草庐IT

data_length

全部标签

C++ std::vector::data 为什么返回的指针索引和 vector 索引不匹配?

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭5年前。Improvethisquestion我在http://www.cplusplus.com/reference/vector/vector/data/中找到了一个std::vector的例子.//vector::data#include#includeintmain(){std::vectormyvector(5);int*p=myve

c++ - zmq-cpp : recv() waits for data despite ZMQ_DONTWAIT being set

我正在尝试使用ZMQ_DONTWAIT标志通过ZeroMQ实现非阻塞接收方法,但是recv()的行为就像在没有标志的情况下被调用:autostart=std::chrono::steady_clock::now();autohave_data=sock_->recv(&reply,ZMQ_DONTWAIT);autoduration=std::chrono::duration_cast(std::chrono::steady_clock::now()-start).count();std::coutsock_是一个zmq::socket_t实例化为REQ套接字。在这种情况下,have_

c++ - 函数/方法重载 C++ : Data type confusion?

我在C++中重载方法时遇到了一些问题。作为问题的一个例子,我有一个类,其中有许多方法被重载,并且每个方法都有一个具有不同数据类型的参数。我的问题:这些方法应该出现在类中是否有特定的顺序,以确保根据其参数数据类型调用正确的方法?classSomeClass{public:...voidMethod(boolparamater);voidMethod(std::stringparamater);voidMethod(uint64_tparamater);voidMethod(int64_tparamater);voidMethod(uint8_tparamater);voidMethod(

class - 为什么 Kotlin 修饰符 'open' 与 'data' 不兼容?

我有一个类:opendataclassPerson(varname:String)和另一个类(class):dataclassStudent(varreg:String):Person("")这给了我一个错误:error:modifier'open'isincompatiblewith'data'如果我从Person类中删除数据就可以了。为什么kotlinopen和数据不兼容? 最佳答案 来自https://kotlinlang.org/docs/reference/data-classes.html:Toensureconsist

class - 为什么 Kotlin 修饰符 'open' 与 'data' 不兼容?

我有一个类:opendataclassPerson(varname:String)和另一个类(class):dataclassStudent(varreg:String):Person("")这给了我一个错误:error:modifier'open'isincompatiblewith'data'如果我从Person类中删除数据就可以了。为什么kotlinopen和数据不兼容? 最佳答案 来自https://kotlinlang.org/docs/reference/data-classes.html:Toensureconsist

c++ - 在循环中使用 string.length() 是否有效?

例如,假设一个strings是这样的:for(intx=0;x比这更好?intlength=s.length();for(intx=0;x谢谢,乔尔 最佳答案 一般来说,如果结果在迭代过程中没有改变,则应避免在循环的条件部分调用函数。因此,规范形式是:for(std::size_tx=0,length=s.length();x!=length;++x);这里注意三件事:初始化可以初始化多个变量条件用!=表示而不是我使用前增量而不是后增量(我还更改了类型,因为负长度是无意义的,字符串接口(interface)是根据std::strin

c++ - 理解错误 "terminate called after throwing an instance of ' std::length_error' what(): basic_string::_S_create Aborted (core dumped)"

所以这是我的错误:terminatecalledafterthrowinganinstanceof'std::length_error'what():basic_string::_S_createAborted(coredumped)这是我的代码://CoderemovedstringgenerateSong(stringlist[],intnum){//Coderemoved//Coderemovedfor(i=0;i我只想知道该错误的含义,以便我知道如何修复它。我看到很多帖子都有类似的错误,但没有完全相同的。从字面上看,我才刚刚开始使用C++,而这些答案对我目前所学的知识都没有任何

c# - 无法将类型为 'System.Data.DataRowView' 的对象转换为类型 'System.IConvertible'

我在C#代码中使用inti=Convert.ToInt32(ddlDivisionId.SelectedValue);当时这种类型的错误累积..Unabletocastobjectoftype'System.Data.DataRowView'totype'System.IConvertible'我该如何解决?请帮忙 最佳答案 看起来您的ddlDivisionId.SelectedValue正在返回一个DataRowView。我假设您将DataTable或类似内容绑定(bind)到您的下拉列表(假设这就是我们正在查看的内容)。在这种情

Python 2.6 : reading data from a Windows Console application.(操作系统?系统?)

我有一个返回一些文本的Windows控制台应用程序。我想在Python脚本中阅读该文本。我曾尝试使用os.system阅读它,但它无法正常工作。importosfoo=os.system('test.exe')假设test.exe返回“bar”,我希望将变量foo设置为“bar”。但实际情况是,它在控制台上打印了“bar”并且变量foo被设置为0。我需要做什么才能获得我想要的行为? 最佳答案 请使用子进程importsubprocessfoo=subprocess.Popen('test.exe',stdout=subprocess

Windows BAT 或 CMD : send some data to a localhost udp port

我有一个监听本地主机端口的应用程序。我想要一个最小的启动器来将该应用程序带到最前面。我的应用程序是用Java编写的。我不知道如何编写任何exe文件,但我可以编写bat文件,然后制作一个快捷方式,在不显示终端的情况下启动bat文件。我想让bat文件将一些数据发送到端口(最好是UDP,这样就不会有任何流开销)。如何将数据发送到UDP端口?我想到的其中一件事是nslookup,但据我所知,它只会连接到端口53。这只需要在Windows上工作。希望它能在XP及更高版本上运行,但如有必要,我可以制定解决方法。 最佳答案 这是netcat的工作