in reply to Re: Re: A little C code converted to Perl *HELP*
in thread A little C code converted to Perl *HELP*
Oh, I almost missed that little part at the end with the sprintf...
DWORD generated_check=(rand()<<16) | rand(); char gcheck[64]; sprintf(gcheck, "%x", generated_check);
My C, as I said, is marginal, but if this is doing what I think it's doing, ...
$gcheck = printf "%x", ((rand() << 16) | rand());
I'm assuming here that the C << operator is a left shift just like in Perl, but that's a wild guess. I'm also assuming that rand with no args in C does the same thing as in Perl, which is also a guess. Like I said, my knowledge of C leaves something to be desired. I know what the Perl code does. (It prints "0" every time.) I'm guessing at the C code. Probably guessing wrong.
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re2 (rand() in C): A little C code converted to Perl *HELP*
by bbfu (Curate) on Nov 03, 2003 at 17:54 UTC | |
Re: Re: A little C code converted to Perl *HELP*
by regnab (Initiate) on Nov 03, 2003 at 04:49 UTC | |
Re: Re: A little C code converted to Perl *HELP*
by regnab (Initiate) on Nov 03, 2003 at 04:53 UTC | |
by jonadab (Parson) on Nov 03, 2003 at 05:00 UTC |