--------------------------------------------------------------------------- Brace Block do { ... } while(0) This may seem non-sensical, as the while loop never loops. It just gets executed once only. However you can use 'break' anywhere in the block to jump to 'escape' to the end of the block. --------------------------------------------------------------------------- Program Name (real, not given) Get argv[0] from the environment (The real file name used not the given name) extern char **environ; /* save as in main(ac,av,ep) */ printf("i am %s\n", environ[-2]); --- Tom Christiansen environ[-2] may be argv[argc - 1], not necessary equal to argv[0]. If you throw in some more nonportable assumptions about argc, integers, and pointers, I'd suggest: char ** argv() { extern char ** environ; int ac = 1; while ((int)environ[ -2 - ac ] != ac) ac++; return environ - (1 + ac); } (I have also seen a compiler provide an `extern char ** __Argv', once.) --- Jutta Degner On (system V Rev 4) you can ask the operation system. #include #include #include char *cmd_name() { char fn[12]; static fd = -1; static prpsinfo_t pr; if (fd == -1) { sprintf(fn, "/proc/%05d", getpid()); if ((fd = open(fn, O_RDONLY)) == -1) { perror(fn); exit(1); } if (ioctl(fd, PIOCPSINFO, (void *)&pr) == -1) { perror("ioctl(PIOCPSINFO)"); exit(1); } } return pr.pr_fname; } --------------------------------------------------------------------------- Argc[0] modification for ps output write individual characters into argv[0][0..n] but if my new name is longer than the old name, your stuck --------------------------------------------------------------------------- convert "Sun Sep 16 01:03:52 1973" into a time_t You can use the 'getdate.y' file from many packages, like 'cnews'. Just 'yacc' it, get the resulting .c file and try it on your compiler.. --- Michel Pollet michel@trantor.uucp --------------------------------------------------------------------------- Multiple peak detection Find distinct peaks in an array of data. Param: delta (defines kind of a tolerance and depends on your data) min = Inf (or some very high value) max = -Inf (or some very low value) lookformax = 1 for every datapoint d [0..maxdata] in array arr do this = arr[d] if this > max max = this maxpos = d endif if this < min min = this minpos = d endif if lookformax == 1 if this < max-delta there's a maximum at position maxpos min = this minpos = d lookformax = 0 endif else if this > min+delta there's a minimum at position minpos max = this maxpos = d lookformax = 1 endif endif ---------------------------------------------------------------------------