/* * genera.c * Created by Claudio Sartori on Tue May 14 2002. * Copyright (c) 2002 __MyCompanyName__. All rights reserved. * */ #include <stdio.h> #include <stdlib.h> #define DIMBUF 80 #include "random.h" int main(argc, argv){ long i,d,N,min,max; char linea[DIMBUF]; FILE *fd; printf("Genera un file di nome \"dati.dat\" costituito da N interi casuali \n"); printf("uniformemente distribuiti fra Min e Max\n\n"); printf("Inserire N, Min e Max \n"); fgets(linea,DIMBUF,stdin); sscanf(linea,"%ld %ld %ld",&N,&min,&max); fd = fopen("dati.dat","wb"); for (i=0;i<N;i++) { d = randN(max-min) + min; fwrite(&d,sizeof(long),1,fd); } printf("Scritti %ld records\n",N); fclose(fd); return 0; }