0

I am using Visual Studio 6 and want to read a pipe delimited file, edit some fields and save the file. What would be the best approach for this? Could ADO help me for example? Or maybe Boost? Although I have looked into the Boost string stuff and it doesn't support VC6. Can STL help?

Sorry to ask but I don't want to waste too much time messing around with the different options as time is tight. I've already wasted time looking at Boost only to find that VC6 isn't supported.

Jonnster
  • 3,094
  • 5
  • 33
  • 45
  • 4
    VC6 is not supported at all, by Microsoft as well as by Boost. If you upgrade to a newer compiler your life will be a lot more pleasant. Any reason for not doing this? – Steve Townsend Jul 01 '11 at 12:38
  • 1
    Agreeing to Steve Townsend. VC6 was released when the C++1998 standard came out, therefore does not implement it. Many, many flaws, like `operator new` return 0 instead of throwing an exception, no real code optimization, severely bad template support, severely non-standard extensions; it is older than a decade, older than some young programmers, it does not know the world after 1998 (all that new Windows and modern C++ stuff); please, please, if you can, ditch it. – Sebastian Mach Jul 01 '11 at 13:51
  • I totally agree. I'm working for a new company who still use VC6 and insist on not upgrading the code. It is prehistoric at best the way development is done around here. I've been used to always working with the latest VS. So much so, I never even considered it a question that needed to be asked in the interview. It's been so many years since I last used VC6 and part of me doesn't even want to remember ;) – Jonnster Jul 04 '11 at 08:45

1 Answers1

2

If the file is purely |-delimited then you can use overloads of getline that allow you to specify a different delimiter. Just read the input "line by line" - each line will be the data up to the next | character - modify the field using string or stringstream and then output it, not forgetting to include a '|' delimiter or whatever you want in your output.

If you also have newlines in your input file to deal with, then it's a little bit more complex - you'd need to read each line into a stringstream using standard getline delimiter (EOL), and then parse and re-output the stringstream using the method I noted above.

Steve Townsend
  • 53,498
  • 9
  • 91
  • 140