How to convert this Pascal loop to c++?

I'm having hard time understanding the loop below , I understand it is used to encrypt strings , But i was wondering about the inc(k) instructions , If the buffer size is over 3 chars it will crash or does inc(k) stop when reaches k[2]?
How would this look like in c++? .

1
2
3
4
5
6
  k:=$de;
  for i:=0 to f.size-1 do
  begin
    m[i]:=m[i] xor k;
    inc(k);
end
Have you looked at http://www.cplusplus.com/doc/tutorial/control/

Why the i (index?) iterates up to f.size-1, but is used to dereference (array?) m?

What does the function inc() do? Is it same as k := k + 1;? C++ has a short-hand for that: ++k;

Line 4 could use compound assignment version of bitwise xor operator: m[i] ^= k;
Thanks for your response , However my main question wasn't answered ,
If the buffer(m[i]) size is over 3 chars will it crash or does inc(k) stop when reaches k[2]?, I'm asking because the instructions seems to be working , However it doesn't make much sense to me , Because k size is 3 chars and the loop go for over 300 chars .
As far as I know, the body of the loop is executed f.size times and therefore the inc(k) is called f.size times.

You have not told the type of k, de, or m. We are not psychics.
Oh right i'm sorry , , I figured it out after doing some research , looks like in Pascal if you write $63 it is a hex value , so $DE is 222 in decimal and it increases with each loop so just like you said k:=k+1 , the dollar sign confused me because i thought k was array of chars , I should have paid more attention , Thanks for your help!.
Topic archived. No new replies allowed.