I am trying to extract the city from the following string;
Kmart, 200 Irwin Ne, Fort Walton Beach FL
The code I made goes through the string and I can extract this;
Fort Walton Beach FL
However, I do not understand how to effectively extract the city. I can extract the state using strlen but that is not working for the city.
void getCity(char strCity[], const char strLine[])
{
char newLine[MAX_CHARS_PER_LINE+1];
char newCity[MAX_CHARS_PER_LINE+1];
strcpy(newLine, strLine);
char* token = strtok(newLine, ",");
if(token != NULL)
{
token = strtok(NULL,",");
token = strtok(NULL, ",");
}
strcpy(newCity, token);
strcpy(strCity, token);