1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| struct gri
{
int n,nt,nb,nl,nr;
float x,y;
struct gri *next, *next1, *next2;
};
typedef struct gri GRI;
GRI * geo;
main()
{
char inputfile[80];
int taille, i;
FILE *fp;
//Lecture du nom de fichier
puts("Enter file name:");
gets(inputfile);
fp = fopen(inputfile, "r");
//initialisation du pointeur
GRI *g=NULL;
//initialisation du pointeur
GRI *g=NULL;
GRI *grd=NULL;
//allocation de memoire
grd=(GRI*)calloc(1,sizeof(GRI));
if(grd==NULL)
{
exit(1);
}
g=grd;
fscanf(fp,"%d",&taille);
geo = (GRI*)calloc(taille,sizeof(GRI));
//remplissage de ma structure et liste chainee
i=0;
while ( !feof(fp) )
{
fscanf(fp,"%d %d %d %d %d %d %d %f %f "
,&geo[i].n,&g->next1,&g->next2,&geo[i].nl,&geo[i].nr,&geo[i].nb,&geo[i].nt
,&geo[i].x,&geo[i].y);
i++;
g->next=(GRI*)calloc(1,sizeof(GRI));
g=g->next;
}
return 0;
} |
Partager