Hello, I have a file that needs to be read in and I would like to capture each line in a nicely delimited fashion. I need to be able to go back to the data, fetch it and use some logic on it. Here is what I have so far:
By "the second printout" I'm going to guess that you meant the second line of your output. And I expect that if you look in the input file ("itinerary.txt") you'll find that the output doesn't have extra commas, it just has commas which are copied from the input to the output.
As for what you should do instead, I'm afraid I have nothing to say. I wouldn't have called your output "nicely delimited" but on the other hand you seem to be satisified with at least the first line. So that means I don't know what you're trying to achieve with that code.
Thanks Paul. What I need to do with this code is read from itinerary.txt and match destinations against the airport/mileage combinations in airports.txt to see if there is a feasible route. So from itinerary.txt, "2, A110, D20" is a reference to route AD<some mileage>. I need to search airports to see if there is an AD??? pairing first to determine if there is even that route.
Hi Paul, I do need to split the string, however I am having trouble determining how to do that at precisely the points I need to. So "2, A110, D20" would need to be split into "2" for number of travelers, "A" for departure airport, "110" for number of miles to it from home, "D" for arrival airport and "20" for number of miles to destination. Thank you.
I am having trouble creating an array that will hold all the values of splitting itineraries. I have test2 declared globally and I'm trying to use it to hold ALL the lines read in and split by br. Any help appreciated.