- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题让一些程序员抓狂。语言是C/C++。考虑下面的代码...假设 request 是一个有效的 C++ 字符串。
string outMsg;
string trans_str = ("</TRANSACTION>");
int32_t position;
//Assign outMsg and find "</TRANSACTION>"
outMsg.assign(request);
position = outMsg.rfind(trans_str);
程序在 rfind(trans_str) 上崩溃。当使用 find(...) 和 replace(...) 时程序也会崩溃。大多数 C++ 方法似乎都有问题。该程序还会在如下行崩溃....
cout << "This is a string " << variable << "and this is the end"; //this is an example
程序通常会在第三个“<<”处崩溃,并且只会在本例中打印以下输出:
“这是一个字符串{变量}” CRASH。
这里发生了很多奇怪的事情。
包含“字符串”(在尖括号中)。
谢谢!
最佳答案
您的代码片段非常不完整,但是当我用我认为可能有意义的内容填充空白时,它对我来说运行良好......
#include <iostream>
#include <string>
int main()
{
std::string outMsg;
std::string trans_str = ("</TRANSACTION>");
int32_t position;
std::string request = "abcdefg</TRANSACTION>hijklmnop";
//Assign outMsg and find "</TRANSACTION>"
outMsg.assign(request);
position = outMsg.rfind(trans_str);
std::string variable = outMsg.substr(position, outMsg.size()-position);
std::cout << "This is a string\n" << variable << "\nand this is the end\n"; //this is an example
}
关于c++ - rfind 和 << 崩溃程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11266972/
在Lua中,只有string.find,但有时需要string.rfind。例如,要解析目录和文件路径,例如: fullpath = "c:/abc/def/test.lua" pos = strin
我对 Django 真的很陌生,所以我仍然习惯了表单。我正在尝试在 Django 中发送一封电子邮件,使用表单中所有清理过的数据,包括上传的文件,但我收到错误“FieldFile' 对象没有属性 'r
我正在解析一堆文件以获取特定的网址.. 子目录可以是大写、小写或驼峰式: search = "http://website.com/content/" + subdirectory + "/?" be
我有一个问题让一些程序员抓狂。语言是C/C++。考虑下面的代码...假设 request 是一个有效的 C++ 字符串。 string outMsg; string trans_str = ("");
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
过去我使用 line.rfind 来查找固定变量,并且我的脚本运行良好。然而,现在我尝试使用 line.rfind 来查找变化的变量,我收到了一行曾经有效的代码的语法错误。这是我的代码。 #!usr/
根据 c++ 教程和有关 find() 的教学,实现了以下代码以搜索 string 中所有出现的“cat”: std::string input; std::size_t i = 0, x_appea
我是Python新手,我正在尝试使用find实现rfind函数。 def rfind_imp(s,t): ss = s fpos = 0 while(True):
我正在尝试使用 os.path.splitext 确定文件扩展名 这是我的代码: for emailid in msgs: typ, s = mail.fetch(emailid, "(RFC
www.mydomain.com/invite/abc123 我希望函数返回“abc123”。逻辑是这样的: If there is a forward slash, then take all ch
我需要一个函数来搜索右侧的输入。我想从右边(而不是像使用 .find 那样从左边)找到第一个“)”。 .rfind 来自 python,所以我需要它在 Java 中的等效项。 有什么想法吗?谢谢!!
我已经安装了 rails.vim,它似乎从 :Rails! 开始就安装正确了。返回 rails.vim 5.0 . 但是,如果我在现有的 Rails 项目中查找文件 :Rfind user我得到 E4
我的 linux 机器上有一个采用这种结构的项目: project/ changelog README src/ install.sh
当我结合使用 petsc4py 和 cython 时遇到错误:AttributeError: 'list' 对象没有属性 'rfind' 下面的代码是.../petsc4py/demo/wrap-cy
当应用于数组时,index(用 block 调用)返回满足条件的第一个元素的索引,rindex 返回最后一个元素的索引.同样,我们有 find 来返回元素本身。但是,没有相应的 rfind 会返回满足
我是 Python 的新手,有些事情正在发生。基本上,当我对字符串调用 str.rfind("test") 时,输出与 str.find("test") 相同。我最好给你举个例子: Python 2.
我正在尝试编写一个函数,该函数将从给定路径遍历一系列子文件夹,并解压缩其中以 .fastq.gz 结尾的所有文件,而不会影响其他文件。 我知道还有其他方法可以解决此问题,但稍后在我的程序中,依赖相同原
我是一名优秀的程序员,十分优秀!