Help with files

So I am awful when having to use data or .txt files. I believe my code is right, I just don't know how to upload the files. Please, any help will do. Here is the description of the assignment and the coding:

Process the input file containing latitude and longitude data of US cities in degree, minutes, and seconds. Output the processed information in decimal degrees.

a) Write a C++ program to read each line of the input file, store each data line in an array of structure, calculate the degrees in decimal for latitude and longitude, store these values in the corresponding structure and write the results to the output file by processing the array.

b) Use vectors or dynamic array to optimize memory usage. Specify the design choice in your main comment for the program.

c) Split the City and State and store it in two separate fields.

d) Search a city and find it in the array of structure and print out ALL the information on the screen.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <fstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

struct City
{
	string areaCode;
	double latitude;
	double longitude;
	string city;
	string state;
};

/**
 } */
Last edited on
i just skimmed it, but your code looks fine to me. very straightforward and easy to follow (could do without the comments though). anyways, what do you mean upload it? like to a remote server?
I'm sure you can see I have to do this with a .txt data file. But it wasn't reading. I thought something was wrong with my code.
yes i can see that, but thats not uploading a file. also, are you sure the file exists? and that you can write to the location?
Topic archived. No new replies allowed.