Browse Source

added basic options handling

master
tth 2 years ago
parent
commit
495a7cf3cf
2 changed files with 20 additions and 3 deletions
  1. +19
    -2
      fake-values.c
  2. +1
    -1
      funcs.c

+ 19
- 2
fake-values.c View File

@ -3,16 +3,33 @@
*/
#include <stdio.h>
#include <unistd.h>
#include "funcs.h"
int verbosity;
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__);
int opt;
while ((opt = getopt(argc, argv, "v")) != -1) {
switch (opt) {
case 'v': verbosity++; break;
default: break;
}
}
if (verbosity > 1)
fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__);
verbosity = 1;
printf("%f %d\n", dtime(), random1000(0));
return 0;
}
/* --------------------------------------------------------------- */

+ 1
- 1
funcs.c View File

@ -16,7 +16,7 @@ int random1000(int foo)
{
int value;
if (verbosity)
fprintf(stderr, "%s(%d)\n", __func__, foo);
fprintf(stderr, ">>> %s(%d)\n", __func__, foo);
value = rand() % 1000;
return value;
}


Loading…
Cancel
Save