-4

So, i have a school project to build the uberEats management system in C.

I have a csv file that contains the cities where the system is available and their respective code. Eg: 1, New York.

And i need to read that file, so when the user inserts one code, it associates to the specific city. Can anyone help me how to do that?

  • 3
    Have you tried anything? – Eugene Sh. Jan 15 '19 at 18:43
  • That really depends on the format of your file, if you don't have gaps between id's you can load the data into an array, in other case you need another type of data structure, i.e. a hashmap. – David Ranieri Jan 15 '19 at 18:48
  • There's insufficient information for a meaningful answer - how many cities are there? What have you tried? Where exactly would the user be inputting the code? If you're simply trying to relate a city to some integer code, some sort of [associative array](https://en.wikipedia.org/wiki/Associative_array) or map would be a good option. – Daniel Jan 15 '19 at 18:52
  • Using some sort of database like sqlite instead of CSV files would be a good idea. – Shawn Jan 15 '19 at 18:57

1 Answers1

0

you could read the file and make a matrix of 2xno_cities, and when the user puts a number, you just do

array[input-given-by-user][1]

since the first [] would be for the row, and the second one for the column, which is where you save the cities,

Duke
  • 19
  • 7