Wednesday, 2 October 2013

How to separate a string into 4 separate arrays

How to separate a string into 4 separate arrays

Ok so to start off i'm a beginner to objective c. I got a project where
i'm suppose to take a csv file and read it into the system into 4 separate
arrays, (City, Country, Latitude, and Longitude. My first question is can
you use the old school string instead of NNString. I did the same project
in c++ and this is what i got.
`ifstream file("worldcities.csv");
getline(file, temporay);
//inputs the file into 4 arrays for each catergories
for (i=0;getline(file,(cities[i]),',');i++)
{
getline(file, countries[i], ',');
getline(file, latitude[i], ',') ;
getline(file, longitude[i]); }'
How can i get the same outcome in Objective c? I tried fgets instead of
getline but i'm still not familiar with it so thats why i come to you
guys. I really do appreciate the help

No comments:

Post a Comment