PIPS
gen_floats.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+ Include dependency graph for gen_floats.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 8 of file gen_floats.c.

9 {
10  if (argc < 2)
11  {
12  fprintf(stderr, "Usage: %s nb_floats\n", argv[0]);
13  return EXIT_FAILURE;
14  }
15 
16  int i;
17  int n = atoi(argv[1]);
18  unsigned int seed;
19  int frand = open("/dev/urandom", O_RDONLY);
20  read(frand, &seed, sizeof(unsigned int));
21  close(frand);
22 
23  srand(seed);
24  for (i=0; i < n; i++) {
25  float f = (float) rand();
26  fwrite(&f, sizeof(float), 1, stdout);
27  }
28  fflush(stdout);
29 
30  return EXIT_SUCCESS;
31 }
#define EXIT_SUCCESS
NetBSD 5.0 mis-defines NULL.
Definition: stdlib.in.h:103
#define EXIT_FAILURE
Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere with proper operation of xarg...
Definition: stdlib.in.h:108
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
static Menu_item close
Definition: xv_log.c:66

References close, EXIT_FAILURE, EXIT_SUCCESS, f(), and fprintf().

+ Here is the call graph for this function: