Can someone please explain to me because i do not understand the
tutorials on pointers.

anyways i have a struct:

struct driver {
 int id;
 char name[30];
 int runs;

//I am reading a file which goes in order ID NAME RUNS as:  1 Super Man 5
//I am reading it from a file like so:

struct drive *read(char *file){
	int x = 1;
	FILE* open;
	open = fopen(file,"r");
		struct drive *drive1;
		drive1 = (struct drive*) malloc(sizeof(struct drive));
		fscanf(open, "%d", &drive1->id);
  		fscanf(open,"%s", drive1->name);
		printf("%d", drive->id);
		printf("%s", drive->ime);


What am i doing wrong here ?

Can someone take a looka at the last printf and tell me why can i print out
my value.

struct voznja *beriVoznje(char *datoteka){
	FILE* open;
	open = fopen(datoteka,"r");
		struct voznja *drive;
		drive = (struct voznja*) malloc(sizeof(struct voznja));
		fscanf(open, "%d", &drive->id);
  		fscanf(open,"%s", drive->ime);
 		fscanf(open,"%s", drive->priimek);
 		fscanf(open,"%d", &drive->meritve);
		//printf("%d", drive->id);
		//printf("%s", drive->ime);
		//printf("%s", drive->priimek);
		//printf("%d", drive->meritve);
		for (int i = 0; i <= drive -> meritve; i++){
			fscanf(open,"%f", &drive->x[i]);
			fscanf(open,"%f", &drive->y[i]);
			printf("%f", drive->x[3]);
This article has been dead for over six months. Start a new discussion instead.