I've been stuck on this for hours, and have scoured the internet for any insight on this particular issue with no luck.
I'll simplify the problem here.
I have a lines in an input file:
1 2 3
|
John Smith 1234 Main St New York
Carol Thomas 5678 5th Ave Columbus
...
|
and I am reading into character arrays using code like this:
1 2 3
|
infile.getline(name,20);
infile.getline(street,15);
infile.getline(city,10);
|
but when I print the output using something like this:
1 2
|
outfile << "Owner Name: " << name << endl;
outfile << "Address: " << street << city << endl;
|
(let's pretend I included spaces between the address components, which I omitted to save space)
I get an output file of:
1 2
|
Owner Name: John Smith
Address:
|
The output stops after the name variable, which I believe is stored correctly.
I don't think anything is storing in the address pieces, this is the problem.
I think it's because I'm not using getline() properly in this case. Can you string together multiple getline()s like that?
If this were my design, I'd read in strings instead, but that is not possible in this case.
Any help is greatly appreciated.