输出总是 65535 个字符?
Output always 65535 characters?
这是我的代码。
#include <iostream>
using namespace std;
int main()
{
string s;
cin >> s;
cout << s.length();
return 0;
}
为什么即使我增加 s 中的字符,它也会给出 65535 的输出。 我在这里添加了 samle 输入 https://ideone.com/c2V8YX
Ideone FAQ 回答:
源代码、输入和输出的大小限制是多少?
64 kB.
请注意,此限制与C++语言无关,甚至与它的特定实现无关。限制是由Ideone造成的(这是可以理解的。您不希望允许人们上传无限的数据来填充您的服务器(。看来他们的行为是静默地截断输入。
这不是一个完全很棒的代码,但总体思路似乎是合理的。基本上读取块并附加它们(可能附加到 buffewr 而不是原始字符串(,但你明白了
#include <iostream>
using namespace std;
int main() {
string all;
char snippet[100];
while(cin.get(snippet, 100)){ all += snippet; }
cout<< all.length() << 'n';
return 0;
}
相关文章:
- C++字符*缓冲区的大小
- HEX值到wchar_t字符(UTF-8)的转换
- 为什么 Serial.println(<char[]>);返回随机字符?
- 我的字符计数代码计算错误.为什么
- 字符串-C++后显示的随机字符
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 如何在C++中从字符串中分割字符
- 为什么msgrcv()将垃圾字符馈送到缓冲区
- 指向指向字符数组的指针数组的指针
- 如何用转义符替换字符串中的所有特殊字符
- 大于65535的C++数组[size]引发不一致的溢出
- 为什么 sscanf 无法从一个字符串中读取uint64_t和字符?
- 比较字符数组
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 如何在C++中确定文本文件中的元素是字符还是数字
- 如何将一个ostringstream十六进制字符串字符对转换为单个unit8t等价的二进制值
- 输出总是 65535 个字符?
- Arduino不支持使用websocket协议发送超过65535个字符的消息