为什么我在输出的末尾得到额外的字符?
Why am I getting extra character at the end of my output?
int start = 0;
int end = 0;
string temp = "<sasadfsadfsady>40000</sadsfasdfsadflary>";
for (int i = 0; i < temp.length(); i++){
if (temp[i] == '>' && start == 0) //will only save first one
start = i;
if (temp[i] == '<')
end = i-start; //will be overwritten by the second one
}
temp.erase(temp.begin(), temp.begin()+start+1);
temp.erase(temp.begin() + end-1, temp.end());
cout << endl;
cout << temp << end;
输出:400006
为什么6在最后?我不知道为什么会发生这种情况,请帮助我
<< end
应该是
<< endl
它现在输出6,因为int
变量end
的值为6。
相关文章:
- C++,在int数组中输入字符串或字符会输出0,而不是ascii或error
- 字符的输入/输出操作
- 如何读取单个字符并在输入两个字符序列时输出? 使用 while 循环和C++
- C++输出奇怪的字符而不是数字 (Windows)
- 如何存储 unicode 字符并将其输出到文件?
- C++中附加的字符*的奇怪输出
- 来自无符号字符缓冲区的虚拟输出
- 将未签名的字符写入输出文件
- 在大小为 10 的 char 数组中输入超过 10 个字符的字符串并输出时,它会显示整个数组而不是前 10 个数组.为什
- 如何在C++中正确地将我的语言字符输出到HTML文件中
- x86 上的指针大小和奇怪的字符输出
- 如何修复C++中的随机字符输出?
- Visual Studio-怪异的字符输出
- 需要我当前的字符输出,这是它在C++中的整数值
- 宽字符输出结果
- 将字符输出随机化为文本文件
- C++和printf-奇怪的字符输出
- 显示无符号字符*和有符号字符*输出的结果是否完全相同
- 下一个回文 .奇怪的字符输出
- 不要将宽字符输出到命令提示符