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.
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
stringorstringstreamand 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
stringstreamusing standardgetlinedelimiter (EOL), and then parse and re-output thestringstreamusing the method I noted above.