Why is the command line arguments count variable (traditionally argc
) an int
instead of an unsigned int
? Is there a technical reason for t
By setting it to int, the range is limited to between 1 and INT_MAX inclusive. This will typically mean that no accidental cast or alias will take it out of range from an inadvertent wrap around. It also allows implementations to use the entire negative and 0 range for system specific scenarios.
Ok, I just made that up. The real reason is that it was just an arbitrary decision that one of the original C language developers made, and nobody really thought that hard about it until now. :)