vendredi 28 octobre 2016

VBMATH.Randomize(Double) equivalent in C

I'm shuffling a string called STR in VB using:

    For K = 1 To Len(Str)
        Sk = Sk + Asc(Mid$(Str, K, 1))
    Next K

    Rnd(-1)
    Randomize(Sk)

    For K = 1 To Len(Str)
        RndPos = 1 + Fix(Len(Str) * Rnd)
        ' SWAP Chars
        Tmp = Mid$(Str, K, 1)
        Mid$(Str, K, 1) = Mid$(Str, RndPos, 1)
        Mid$(Str, RndPos, 1) = Tmp
    Next K

I would like to unscramble it in C code on AIX, i can't however find the equivalent of Randomize(double) from VBMATH.

Is there an easy way around it ?

I know that i can seed C's rand() function with srand, but i'm stuck after that.. all the online resources are for C#.

Any help will be appreciated !

Cheers.




Aucun commentaire:

Enregistrer un commentaire