Why is int rather than unsigned int used for C and C++ for loops?

后端 未结 10 2091
日久生厌
日久生厌 2020-12-02 15:50

This is a rather silly question but why is int commonly used instead of unsigned int when defining a for loop for an array in C or C++?

<         


        
10条回答
  •  长情又很酷
    2020-12-02 15:55

    I use int cause it requires less physical typing and it doesn't matter - they take up the same amount of space, and unless your array has a few billion elements you won't overflow if you're not using a 16-bit compiler, which I'm usually not.

提交回复
热议问题