how would i remove all the white space from an istream and replace them with "-" before producing an ostream?
Usura
0
Light Poster
Recommended Answers
Jump to Postmaybe
string rem ( string t ) { int s_t = t.length(); for ( int i = 0; i < s_t; i++ ) { if ( t[i] == ' ' || t[i] == '\n' || t[i] == '\t' ) { t[i] = '-'; } } return t; …
Jump to Post
What??? That will not replace white spaces with '-' character.Why not? Am I missing the point completely or what?
input:
hello test test hello 1 2 3
output:
hello-test-test-hello-1-2-3-
Voila, all whitespace has been replaced with "-". That's what the OP …
All 5 Replies
iamthwee
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
Ancient Dragon
commented:
My bad -- you are right :)
+36
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.