Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Frustrated [modified]

Frustrated [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structurestutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    antonaras
    wrote on last edited by
    #1

    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 spaces string 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 file This 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 form This 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

    Y S 2 Replies Last reply
    0
    • A antonaras

      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 spaces string 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 file This 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 form This 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

      Y Offline
      Y Offline
      YaronNir
      wrote on last edited by
      #2

      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 :)

      A 1 Reply Last reply
      0
      • A antonaras

        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 spaces string 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 file This 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 form This 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

        S Offline
        S Offline
        Saurabh Garg
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • Y YaronNir

          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 :)

          A Offline
          A Offline
          antonaras
          wrote on last edited by
          #4

          thanks for the reply my queue is of type char queuePlainText;

          1 Reply Last reply
          0
          • S Saurabh Garg

            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

            A Offline
            A Offline
            antonaras
            wrote on last edited by
            #5

            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.

            D 1 Reply Last reply
            0
            • A antonaras

              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.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups