program to replace comm and space with tabs

Discussion in 'C++' started by channu, May 4, 2006.

  1. channu

    channu Guest


    I am beginner in c++ coding.I want to read a text file and replace
    commas and space with tabs.

    Can any buddy help me out.
    channu, May 4, 2006
    1. Advertisements

  2. channu

    benben Guest

    Give your code we'll see how to help you.

    benben, May 4, 2006
    1. Advertisements

  3. channu

    osmium Guest

    There are a huge number of ways to do this, some of them quite impressive to
    look at with iterators liberally sprinkled with the all purpose word
    "const". IMO, there is no one "right" way to do it.

    I would write a while loop, examine each character as it came in, and if it
    were a comma or a space, I would replace the character with the tab
    osmium, May 4, 2006
  4. channu

    JS92647 Guest

    Osmium is on the right track. I did a similar thing a few months ago.
    Basically all you have to use is fstream to open up a file, and if it
    finds a "," or a similar character, replace it with something else.
    There is a specific function for this but I can't recall it off the top
    of my head.

    Oh, and questions like these are best left for google :).
    JS92647, May 6, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.