go through every combination ie(0,0,0,0),(0,0,0,1), .... ,(3,3,3,3)

But in a general way such that it's always 0-3, but it may be 4 digits or it may be 5 digits or any other number?

If I know the length I could do nested for loops, but since I don't...is there an effecient and general way to do it?

It is basically the same as counting in base 4.