Appfs Exercise 1: data generator.
More...
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
|
int | main (int argc, char **argv) |
| Generate n random integer numbers and write them to stdout. More...
|
|
- Author
- Thorsten Koch
- Date
- 24Oct2014
gcc -std=c99 -O2 -o ex1_gen -static -m32 ex1_gen.c
Definition in file ex1_gen.c.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
The first number is 123456789; Every 1000037 number the number is negative.
Definition at line 15 of file ex1_gen.c.
17 const char* usage =
"usage: %s count\n";
21 if (argc < 2 || atoi(argv[1]) < 1)
23 printf(usage, argv[0]);
26 const int r = 123456789;
27 int n = atoi(argv[1]);
31 fwrite(&r,
sizeof(r), 1, stdout);
33 for(
int i = 0; i < n; i++)
37 if (0 != i && 0 == (i % 1000037))
41 fwrite(&r,
sizeof(r), 1, stdout);