मैं नीचे टुकड़ा बाहर कोशिश कर रहा था, लेकिन यह वांछित आउटपुट न जताए:अंतर stringstream और ostringstream
#include<iostream>
#include<sstream>
using namespace std;
void MyPrint(ostream& stream)
{
cout<<stream.rdbuf()<< endl;
}
int main()
{
stringstream ss;
ss<<"hello there";
MyPrint(ss); //Prints fine
ostringstream oss;
oss<<"hello there";
MyPrint(oss); //Does not print anything
getchar();
}
मुझे पता है कि stringstream
और ostringstream
के बीच ही संभव मतभेद है कि बाद में बलों की दिशा और stringstream
से थोड़ा तेज है।
क्या मुझे कुछ भी याद आ रहा है?
पीएस: एक समान प्रश्न पहले पोस्ट किया गया था लेकिन उसे कोई जवाब नहीं मिला।