All pastes #799368 Raw Edit

Anonymous

public text v1 · immutable
#799368 ·published 2007-11-27 16:16 UTC
rendered paste body
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>

struct Foititis{
	char am[10];
	char epi[20];
	char ono[20];
	float mo;
};

struct IFoititis{
	char am[10];
	int dief;
};

main(){
	char oad[30],oai[30];

	struct IFoititis foi;

	FILE *dataf;
	FILE *indexf;

	int pl,i;

	printf("\n\nEisagwgi onomatos archeiou (xwris proektasi): ");
	gets(oad);
	strcpy(oai, oad);
	strcat(oai, ".ndx");

	indexf = fopen(oai, "rb");
	fseek(indexf, 0, SEEK_END);

	pl = ftell(indexf) / sizeof(struct IFoititis);
	fseek(indexf, 0, SEEK_SET);

	printf("\n\nARCHEIO EYRETIRIO\n\n");
	for (i=0; i<pl; i++) {
		fread(&foi, sizeof(struct IFoititis), 1, indexf);
		printf("%s == %d\n", foi.am, foi.dief);
	}

	fclose(indexf);
}