Oh I see, sorry it's not a duplicate. Still seems unnecessary to me though, although the benefit of this is that you only have to parse the data once. Still, at only 180 values, unless you're programming a ZX81 or something, scanning through that 180 times is still going to take a few milliseconds at the worst. Is it necessary to store intermediate data, and if so why?
> I felt having array indices like arr[abs(*p)] is not appropriate
You need to explain comments like this. Why don't you feel that is appropriate? If that's not appropriate, what would be, and why didn't you code it that way in the first place?
> And the overall logic, I believe is not good
Again, why exactly? What logic would be good? Statements like this make no sense if they are not explained.
> printf("0 is not a valid latitude\n");
Why is zero not a valid latitude? What is the latitude of the equator?
seems to suggest the equator's latitude is 0.
> Also, to store latitude values -90 to -1, I've used array ranges 1 to 90 and for 1 to 90 I've used 90 to 180. Is there any other way to do this?
Well, you could create a values array (let's call it v_arr) from 0 to 181 and an integer pointer to the midpoint, i.e. int *i_ptr=&v_arr; Then you can use the values -90 to +90 as indices into i_ptr, thus treating it as if it were defined as int i_ptr[-90...+90], which is a sort of C/Pascal hybrid definition and otherwise impossible in C. Negative indices are perfectly OK in C, as long as the resulting address points to valid memory. It's essentially the same thing. Or you could simply add 90 to the latitude values and store data in v_arr[lat+90] which again more or less amounts to the same thing. Using negative indices will make anyone reviewing your code think twice, check carefully and deduce that you must be smarter than they originally thought, but only IF you've done it right!