I try to remove the spaces from a string
using an old trick that involves an
istringstream object. I expect the while-condition
while(istringst ream>>string) to evaluate to
false once the istringstream is exhausted, but
that is not the case. What am I missing?
#include<iostre am>
#include<sstrea m>
#include<string >
static std::string s="Asymmetric Beards, \
Not Even Punk Rockers Have One!";
int main(int,char** )
{
std::istringstr eam a(s);
std::string b;
while(a>>b)std: :cout<<b.c_str( );
return 0;
}
.......
output
AsymmetricBeard s,NotEvenPunkRo ckersHaveOne!On e!One!One!One!O ne!One!...
-X
using an old trick that involves an
istringstream object. I expect the while-condition
while(istringst ream>>string) to evaluate to
false once the istringstream is exhausted, but
that is not the case. What am I missing?
#include<iostre am>
#include<sstrea m>
#include<string >
static std::string s="Asymmetric Beards, \
Not Even Punk Rockers Have One!";
int main(int,char** )
{
std::istringstr eam a(s);
std::string b;
while(a>>b)std: :cout<<b.c_str( );
return 0;
}
.......
output
AsymmetricBeard s,NotEvenPunkRo ckersHaveOne!On e!One!One!One!O ne!One!...
-X
Comment