Well you've taken the code out of context, so it's really hard for me to tell what's actually going on. I'm also not sure if you have pointers or references or what. Please post some more code.
You are probably just going past the bounds of the array, and accessing memory causing a segmentation fault. Try doing a check to see if "i" points to the end of the array, and then if that is the case point to pArray[0] instead.
Also, options 1) and 2) are both perfectly alright, though option 2 is normally preferred in your case due to readability.