Frustrated [modified]
-
Hi again guys i have a strange problem. i'm reading from a file character by character and i'm pushing the characters into a queue like this
do{ c = getc (pFile); plainText.push(c); } while (c != EOF);
so far so good then i copy the content of the queue into a string but i try to remove all unessesary spacesstring text; while (!PlainText.empty()) { if (PlainText.front()!=' ') { Plain_Text+=PlainText.front(); PlainText.pop(); } else if(PlainText.front()==' ') { while(PlainText.front()==' ' && !PlainText.empty() ) { PlainText.pop(); } Plain_Text+=" "; } }
I'm not sure if i made my self clear so i'll give you an example. lets say i have this writen in a fileThis is writen in a text file but with more than one spaces in between the words
i want to copy the contents of this file into the string but in this formThis is writen in a text file but with more than one spaces in between the words
My code doesn't make any changes it lives all the spaces as they where any ideas pls help Thanks a lot -- modified at 6:13 Sunday 11th June, 2006 -
Hi again guys i have a strange problem. i'm reading from a file character by character and i'm pushing the characters into a queue like this
do{ c = getc (pFile); plainText.push(c); } while (c != EOF);
so far so good then i copy the content of the queue into a string but i try to remove all unessesary spacesstring text; while (!PlainText.empty()) { if (PlainText.front()!=' ') { Plain_Text+=PlainText.front(); PlainText.pop(); } else if(PlainText.front()==' ') { while(PlainText.front()==' ' && !PlainText.empty() ) { PlainText.pop(); } Plain_Text+=" "; } }
I'm not sure if i made my self clear so i'll give you an example. lets say i have this writen in a fileThis is writen in a text file but with more than one spaces in between the words
i want to copy the contents of this file into the string but in this formThis is writen in a text file but with more than one spaces in between the words
My code doesn't make any changes it lives all the spaces as they where any ideas pls help Thanks a lot -- modified at 6:13 Sunday 11th June, 2006you didn't mention what type is your queue ? write here the definition of the queue Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)
-
Hi again guys i have a strange problem. i'm reading from a file character by character and i'm pushing the characters into a queue like this
do{ c = getc (pFile); plainText.push(c); } while (c != EOF);
so far so good then i copy the content of the queue into a string but i try to remove all unessesary spacesstring text; while (!PlainText.empty()) { if (PlainText.front()!=' ') { Plain_Text+=PlainText.front(); PlainText.pop(); } else if(PlainText.front()==' ') { while(PlainText.front()==' ' && !PlainText.empty() ) { PlainText.pop(); } Plain_Text+=" "; } }
I'm not sure if i made my self clear so i'll give you an example. lets say i have this writen in a fileThis is writen in a text file but with more than one spaces in between the words
i want to copy the contents of this file into the string but in this formThis is writen in a text file but with more than one spaces in between the words
My code doesn't make any changes it lives all the spaces as they where any ideas pls help Thanks a lot -- modified at 6:13 Sunday 11th June, 2006Do you want to convert a multiline string into a single line one. Although you talk about removing extra spaces but from the example it seems you want to remove newline ('\n') character. -Saurabh
-
you didn't mention what type is your queue ? write here the definition of the queue Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)
-
Do you want to convert a multiline string into a single line one. Although you talk about removing extra spaces but from the example it seems you want to remove newline ('\n') character. -Saurabh
-
Hey thanks for the reply yes i also whant to remove newline but spaces in between as well the example is not clear because when i post the message my spaces where removed.
antonaras wrote:
...when i post the message my spaces where removed.
Use ampersand nbsp; in your post.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb