问题标签 [sstream]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - 为什么 stringstreams rdbuf() 和 str() 给我不同的输出?
我有这个代码,
给我这个输出
ss.rdbuf()->str() : hej hej med dig
ss.rdbuf() : hej med dig
但这是为什么呢?是不是因为 ostreams 对 operator<str() 的定义给了我不同的输出。在我看来,即使我使用了 getline,输出也应该是相同的。
c++ - 让 C++ 类像自定义 ostream、sstream
我有一个 C++ 类MyObject
,我希望能够像向 osstream 一样提供这些数据(但与直接 sstream 不同,传入数据以特殊方式格式化)。我似乎无法弄清楚如何为 MyObject 重载运算符以吃给它的输入。
我想要它,这样每一个送入的物品都被: : 包围
所以在给定的例子中,s = ":Hello::12345" 应该是最终结果。我的问题是,我怎样才能告诉对象,当有 a 时<<something
,将 :: 放在某物周围。
这可能吗?
c++ - C++ stringstream 返回额外的字符?
我一直在尝试使用 C++ stringstream 类来做一些相对简单的字符串操作,但是我遇到了 get() 方法的问题。出于某种原因,每当我逐个字符地提取输出时,它都会附加最后一个字母的第二个副本。
该程序的输出是:
您可以在这方面给我的任何帮助将不胜感激。
c++ - sstream not working...(STILL)
I am trying to get a double to be a string through stringstream, but it is not working.
#xA;It outputs only "0:" on my console...
I'm working on two projects, both with the same problem. I'm posting a different one, which runs into the same problem. It is posted here:
http://pastebin.com/m2dd76a63
I have three classes PolyClass.h and .cpp, and the main. The function with the problem is PrintPoly. Can someone help me out? Thanks a bunch!!
c++ - 如何用 C++ 解析复杂的字符串?
我试图弄清楚如何使用“ sstream
”和 C++解析这个字符串
它的格式是:“string,int,int”。
我需要能够将包含 IP 地址的字符串的第一部分分配给 std::string。
这是此字符串的示例:
然后我需要获得
我会再次提到我不能使用boost
图书馆,只是sstream
:-)
谢谢
c++ - 将未知类传递给 C++ 中的字符串流
我正在使用模板函数,并且正在传递,我可能正在将各种类的实例发送到字符串流。我能做些什么来确保这继续有效?
让我更具体一点,我在哪里定义这个行为?是否有一些成员应该在每个发送到字符串流的类上,我是否应该增强或扩展现有的字符串流(我正在考虑构建一个从 sstream 继承并重载 << 运算符以处理所有可能的类类)?
我什至找不到有关此的文档,因此即使是指向更多资源的链接也会有所帮助。
c++ - 解析流
我正在解析一个包含字符串和数值的文件。我想逐个字段处理文件,每个字段由空格或行尾字符分隔。ifstream::getline() 操作只允许使用单个分隔符。因此,我目前所做的是以字符 ' ' 作为分隔符的 getline,然后在遇到 '\n' 时手动返回到流中的上一个位置:
但是,“seekg”似乎将流定位为一个字符为时已晚(因此我错过了每个换行符之前每个字段的第一个字符)。我知道还有其他方法可以通过逐行扫描等方式来编写这样的解析器,但我真的很想了解为什么这段特定的代码会失败……
非常感谢你!
c++ - 没有冲洗的自定义ostream?
目前,我使用自定义 stringbuf 派生对象创建了一个 ostream,但它使用 sync() 在屏幕上打印文本。有没有办法避免冲洗它?我真的很想做 logStream << "Test"; 没有 std::flush 或 endl。
c++ - 聚合 'std::stringstream out' 的类型不完整,无法定义 [C++]
我是 C++ 新手,请帮我弄清楚这有什么问题
string - Convert an ostream into a string (not a sstream)
I specifically need to convert an ostream into a string. To be more precise, I have a function:
(This function is mainly used for a polymorphic overcharge of the << operator) In this case, I need to get what is in the ostream into the string. After some research, I tried this:
But the string only contains 0s. Does anyone have a solution for this ?
Thank you