I am only learning c and I am trying to implement a for loop from an algorithm. I am so so confused in how to implement it, please see my attempt below. Any help or thoughts would be greatly appreciated as I am unsure, does it imply a loop within a loop. Or am I implementing the for loop correctly,
The algorithm states For all possible a = (0,z0,z1,0)
Looop From algorithm
for (z0, z1) = (0x00, 0x00) to (0xff,0xff)
h0 = somemethod( 0x02000000L ⊕ (0x00, z0,z1,0x00)) )
My Attempt
#define WORD32 unsigned int
for (BYTE z = 0x00; z < 0xff; z++)
{
for (BYTE z1 = 0x00; z1 < 0xff; z1++)
{
WORD32 a = (0 << 24 | a1 << 16 | z << 8 | 0);
WORD32 h0 = f(0x02000000L^a);
}
}
So I unsure about the loop and is the below correct
h0 = somemethod( 0x02000000L ⊕ (0x00, z0,z1,0x00)) )
WORD32 a = (0 << 24 | a1 << 16 | z << 8 | 0);
WORD32 h0 = f(0x02000000L^a);
IE how i get
(0x00, z0,z1,0x00)
Update
It is latter ordering: (0, 0), (0, 1), (1, 2), ..., (0, 255), (1, 0), …
It means all possible combinations - the ordering does not matter once you go through them all.
WORD32
. Just use the win32 type,DWORD
which is the same thing.for (z0, z1) = (0x00, 0x00) to (0xff,0xff)
means. Does that count(0, 0)
,(1, 1)
,(2, 2)
, ...,(255, 255)
or does it count(0, 0)
,(0, 1)
,(1, 2)
, ...,(0, 255)
,(1, 0)
, ...?0x00
to0xff
and implemented0x00
to0xfe
, but note thatfor (BYTE z = 0x00; z <= 0xff; z++)
would run forever.^
in the abstract algorithm stand forXOR
(like in C) or for something else?