+ 2
Compare string and stringstrean
String s = "abcd1234"; Stringstream ss; ss<<"abcd"; ss<<"1234"; If(s==ss) Cout<<"yes"; Else Cout<<"no"; And answer is no. But why? What and how are they compares? Because if i compare with "for" loop char by char all is okay.
1 Resposta
+ 10
It should return true for equality checking i edited your code,
#include <iostream>
#include <sstream>
using namespace std;
int main() {
string s = "abcd1234";
string s2;
stringstream ss;
ss<<"abcd";
ss<<"1234";
ss>>s2;
if(s==s2){
cout<<"yes";}
else{
cout<<"no";}
return 0;
}