On Wed, May 26, 2010 at 9:43 AM, Andros Zuna <[email protected]> wrote:
> But how could I test if the command executes if the return value changes?
> ...is there a unix command or other way that generates random/different
> return values??
>
The following C program will return a pseudo-random value every time it's run:
// --BEGIN--
#include <stdlib.h>
int main(int argc, char * argv[])
{
srand(time(0));
return rand() % 256;
}
// --END--
Save it into a file (i.e., main.c) and compile it with GCC:
gcc main.c -o rand
Then, you can execute the program.
./rand
Though if you're only concerned with zero and non-zero then there's
little reason for the range of return values that I've allowed for
(0-255). You could probably get away with changing...
return rand() % 256;
...to...
return rand() % 2;
That will probably increase the likelihood of encountering 0.
(Sorry for the C on a Perl mailing list :P)
--
Brandon McCaig <[email protected]>
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> <[email protected]>
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/