In the below code, the file test.txt has the following data :
    192.168.1.1-90
    192.168.2.2-80    
The output of this is not as expected.
I expect the output to be
192.168.1.1
90
192.168.2.2
80
Any help would be much appreciated.
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
  FILE *fp;
  char *result[10][4];
  int i=0;
  const char s[2] = "-";
  char *value,str[128];
  fp = fopen("test.txt", "r");
  if (fp == NULL)
    printf("File doesn't exist\n");
  else{
    while(!feof(fp)){
      if(fgets(str,sizeof(str),fp)){
        /* get the first value */
        value = strtok(str, s);
        result[i][0]=value;
        printf("IP : %s\n",result[i][0]); //to be removed after testing
        /* get second value */
        value = strtok(NULL, s);
        result[i][1]=value;
        printf("PORT : %s\n",result[i][1]); //to be removed after testing
        i++;
     }}
    for (int k=0;k<2;k++){
        for (int j=0;j<2;j++){
            printf("\n%s\n",result[k][j]);
       }
   }
 }
        return(0);
 }
 
     
    