You were overstepping the bounds of the array. If I'm correct the array is null terminated and you were writing over the null part causing the segfault. Putting less than fixed it because that kept you from touching that last element.
The argv is a double pointer to character data:
so "./my_prog -1 -2 -3" yeilds
argc 4 meaning you have 4 elements but c arrays start at 0 so the max element = 3. You were putting things in what is the 4th slot but for a c array that is [0][1][2][3][4] <- the 5th spot.
You cant test this with:
Code:
int main(int argc, char **argv)
{
int i = 0;
for(i; i < argc, i++)
printf("element %d, data %s\n", i, argv[i]);
}