Here is my latest code based on replies (thank you ). After exiting the while loop, the array still does not maintain the entries I copied into it.
Code:
while(fgets(line, Max, r) != NULL)
{
int i, j;
int index = 0;
int slot = 0;
char *sep;
if(line[0] == '#' || line[0] == '\n')
continue;
sep = strtok(line, delim);
while (sep != NULL)
{
routes[index][slot++] = sep;
sep = strtok (NULL, delim);
}
for (j=0; j<3; j++)
fprintf(o, "After tokenization: %s\n", routes[index][j]);
index++;
}
fprintf(o, "Outside while: %s\n", routes[0][0]);
fprintf(o, "Outside while: %s\n", routes[0][1]);
fprintf(o, "Outside while: %s\n", routes[0][2]);
fprintf(o, "Outside while: %s\n", routes[0][0]);
fprintf(o, "Outside while: %s\n", routes[0][1]);
fprintf(o, "Outside while: %s\n", routes[0][2]);
my output:
After tokenization: 192.0.32
After tokenization: 255.255.255
After tokenization: 206.220.243.34
After tokenization: default
After tokenization: 206.220.243.60
After tokenization: .60
Outside while:
Outside while: 206.220.243.60
Outside while: .60
Outside while:
Outside while: 206.220.243.60
Outside while: .60