I am newbie to C programing and facing below segmentation fault for below code snippet.
`sample.txt` is used as a file input and below is the content of this file.

Below is the content of the `sample.txt` file-

> 
> 
> ```
>           1001:"field1":N
>           1001:"field2":B
>           1001:"field3":A
>           1001:"field4":D
>           1001:"field5":N
>           1001:"field6":N
> 
> ```
> 
> 

This in my Code Snippet-

```
#include <string.h>
#include<stdio.h>
#include<stdint.h>
#include<stdlib.h>
#define MAX_OID_LEN 128
#define MAX_FILE_NAME_LEN 128
#define MAX_BUFFER_SIZE 80
#define MAXSTRINGSIZE 20
#define MAX_VALUE_LEN 128
int8_t* field[MAX_VALUE_LEN]={0,};     

int8_t* type[MAX_VALUE_LEN]={0,};
int8_t field_count=0;   
char * option(int8_t* type[MAX_VALUE_LEN], int8_t* field[MAX_VALUE_LEN])
{

int8_t i=0;
if(*type)
{
while(**type)
{
switch(**type)
{

case 'D':

printf("\nDateType");
printf("\nfield=%s",field[i]);
break;
case 'N':
printf("\nInteger");
printf("\nfield=%s",field[i]);
break;
case 'A':
printf("\nAscii");
printf("\nfield=%s",field[i]);

break;
case 'B':
printf("\nBinary");
printf("\nfield=%s",field[i]);

break;

default:
printf("\nDefault=%s",field[i]);
return *type;
//break;
}
*type++;
i++;
printf("\ni=%d",i);
}
printf("%s",field[i]);

}
return NULL;

//printf("%s",field[i]);
}

int main()
{
int8_t field_count=0;
        int8_t* data_field;
        int8_t* token;
        int8_t* ismp_field;
        int8_t *search = ":";
        FILE *fp;
        int8_t* filename = "sample.txt";
        fp = fopen ( filename, "r" );
        if( fp != NULL )
        {
                int8_t line [MAX_BUFFER_SIZE];
                while ( fgets ( line, sizeof (line), fp ) != NULL )
                {
                        token = strtok( line, search );
                        ismp_field = strtok( NULL, search );
                        data_field = strtok( NULL, "\n" );
                        if(ismp_field!=NULL)
                        {
                                field[field_count]=strdup(ismp_field);
                                printf("\nismp_field=%s\n", ismp_field);
                                type[field_count]=strdup(data_field);
                                printf("\ndata_value=%s\n",type[field_count]);
                                field_count++;
                        }
                }
                fclose ( fp );

}
char *val=option(type,field);
printf("%s",val);
return 1;
}

```