How to print index value in a for loop?

Integer: %d

Hi everyone,

I’m facing a weird issue while programming a class for a UE4 project.
Basically I just want to print on my screen the value that the index of a for loop has reached. As simple as that.

My code:

for (int32 i = 0; i < 4; i++)
				CornerWorldLoc = (*HitTable->GetCorners())[i] + HitTable->GetActorLocation();
				ClickCornerDist = (CornerWorldLoc-MouseClick).Size();

				GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, FString::Printf(TEXT("Index: %f. Click-corner distance: %f"), i, ClickCornerDist));
				/*if (ClickCornerDist < 15.f)

(I commented some lines that I will need later on)

The output of the above lines is the following:


You can see that

  • the value of ClickCornerDist changes in each cycle, so the index i must be working,
  • but when I print i it is always 0.

Why is that? What am I doing wrong?

Note that what I actually need is to pass the value of i to the function “ResizeTable” (commented above), but it always gets 0, that’s why I was trying to print i on the screen and noticed this behaviour.

I’m embarassed :smiley: