So I have this text file which contains data about airports in the following format:
The first part consists of codes and the names of the airport location, the second is a chart representing flight costs from one airport to the other.Code:BUR Burbank FAT Fresno LGB Long Beach LAX Los Angeles MRY Monterey Peninsula OAK Oakland SMF Sacramento SAN San Diego SFO San Francisco SJC San Jose SBO Salina SMO Santa Monica 0 0 0 0 122 0 0 0 0 0 316 0 0 0 0 0 0 0 0 0 321 455 0 0 0 0 0 125 0 0 0 0 267 0 0 0 0 0 125 0 0 50 0 0 250 0 370 0 122 0 0 0 0 259 0 0 0 0 0 119 0 0 0 50 259 0 0 129 0 0 0 0 0 0 0 0 0 0 0 111 0 0 125 0 0 0 0 0 0 129 111 0 0 0 0 0 0 321 267 250 0 0 0 0 0 190 0 0 0 455 0 0 0 0 0 0 190 0 0 0 316 0 0 370 0 0 125 0 0 0 0 145 0 0 0 0 119 0 0 0 0 0 145 0
Obviously, I cannot use the same logic to read both pieces of data, so I need to find a way to stop reading for names and codes once I reach the blank line that separates the two.
I was thinking that I could use the strcmp() function to compare the current line to the next line and continue to scan while the current line is greater than the next (the next only containing a new line character)
I have in mind something like:
Any and all feedback is appreciatedCode:char* current_line, *new_line; //current_line = ?; //new_line = ?; while(strcmp(current_line, next_line) == 1) { //read in data to structure I have already defined }