Possible Duplicate:
Why do most of us use 'i' as a loop counter variable?
I was just writing a nested loop and got to the point where I was using l and m as variables to control for loops, and I realized this could get very confusing; Ive already had a few bugs when I copied blocks of code to different levels. So I was thinking instead of using i,j,k I would use iSomething,iSomethingelse. So if I were going over a 3D model Id use
for(int iMesh=0;iMesh<numMesh;iMesh++)
for(int iVertex=0;iVertex<meshes[iMesh].numVertex;iVertex++)
or maybe use the name of the variable Im iterating over:
for(int iMeshes
for(int iVerts
So I was wondering if there are any other standard or commonly used practices for doing this?
EDIT: Im wondering if there ARE any standards, not if its OK to do this
somethingIndex
format, such astaxEntryIndex
. It is long, but I know exactly what it does. In case of some sort of grid, I would possibly usex
,y
,z
, orcolumnIndex
,rowIndex
,columnNum
,rowNum
, etc. - whatever is most descriptive. – Job Jan 02 '12 at 00:44