#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
trying to put fields into my struct but getting segmentation fault when i strcpy them in
typedef struct country {
    char code_name[3];
    char name[44];
    int population;
    float life_expect;
}country[244];
country *data;
int main(void) {
    char c;
    char *ptr;
    int i;
    int temp;
    char buf[512];
    char *token;
    FILE *fptr;
    fptr = fopen("AllCountries.dat", "r");
in here where i call strcpy(data[i]->code_name, token) i get a segmentation fualt. why is that? what am i doing wrong?
    do {
        if (fgets(buf, 512 , fptr)){
            //printf("%s\n",buf);
            token = strtok(buf,",");
            while (token != NULL){          
            token = strtok(NULL, ",");
                if (temp == 0){
                strcpy(data[i]->code_name, token);
                printf("%s, ",token);
                } temp = temp + 1;
            //printf("%s, ",token); 
            //printf("code_name: %s\n", data->code_name);                   
            }
        i++;
        temp = 0;
        }
    }while ((feof(fptr))  != EOF);
    fclose(fptr);
    return 0;
}
the file
115,DZA,Algeria,Africa,Northern Africa,2381741,1962,31471000,69.7,49982,Al-Jazair/Algérie,Republic,Abdelaziz Bouteflika,35,DZ
146,AGO,Angola,Africa,Central Africa,1246700,1975,12878000,38.3,6648,Angola,Republic,José Eduardo dos Santos,56,AO
94,BEN,Benin,Africa,Western Africa,112622,1960,6097000,50.2,2357,Bénin,Republic,Mathieu Kérékou,187,BJ
129,BWA,Botswana,Africa,Southern Africa,581730,1966,1622000,39.3,4834,Botswana,Republic,Festus G. Mogae,204,BW
193,IOT,British Indian Ocean Territory,Africa,Eastern Africa,78,NULL,0,NULL,0,British Indian Ocean Territory,Dependent Territory of the UK,Elisabeth II,NULL,IO
95,BFA,Burkina Faso,Africa,Western Africa,274000,1960,11937000,46.7,2425,Burkina Faso,Republic,Blaise Compaoré,549,BF
 
     
     
    