Stuck on getting strings from a .dat file

Hello,
Im rather new to programming and have been working on a program that reads a .dat file and changes the only one part of the line, then saves the information to a new file. Anyways let me show you the problem:

Example of the .dat file

"
00000000001001 1 1AZ13/07/301100000000000001783000000000000000000 N51N D051N 02
00000000001007 1 1AZ13/07/301100000000000001939000000041000000000 N51N D051N 02
.
.
.
"
The lines stop after the 02's. The goal is to be able to delete the "D0" from each line. Im struggling mostly on getting the string and editing it. Any help would be a life saver. Thank You
If you want to read a line from the file, you can use getline().
std::getline(file_stream, string_to_read_to);
This will read one line from the file, assuming there is more to read.

http://cplusplus.com/reference/string/getline/
Thanks for the quick response, My current programs does read line by line and out. However I need to replace the "D0" from each line with " " (To keep the right format). Would it be better to approach it string by string? If so how could i accomplish this?
Thank you in advance
Reading it line by line is fine. You just have to remove/replace the substring in question. Is it a fixed column or do you have to match " D0" or something like that? Either, is supported directly by the string class. See the reference section.
closed account (zb0S216C)
lodixcblue wrote:
However I need to replace the "D0" from each line with " "

When you've extracted the line, search through the string[1]. Locate D0. When you've found it, replace it with the appropriate member functions.

References:
[1]http://www.cplusplus.com/reference/string/string/

Wazzak
Last edited on
Topic archived. No new replies allowed.