News for hackers. Stuff that matters.
Re:How to C in 2016 by zAy0LfpBZLC8mAC on Friday January 08, 2016 @09:23AM (#10865003)
You "know the range", but not necessarily in terms of concrete numbers. Often, you iterate over variable size data structures, for example. All you know is that it won't be larger than the C implementation it's being compiled with allows--which usually roughly means that it won't be larger than the amount of memory the processor it's running on can address. But how much that actually is? Well, depends on the processor, and there also is no upper limit, as you always can invent a processor that can address more memory than any processor before. That's why you should usually use appropriate abstract types (such as size_t in this case) that the compiler will make sure are large enough to be able to iterate over any data structure you will encounter on that target.
Re:How to C in 2016 by Nursie on Friday January 08, 2016 @12:25PM (#10866511)
Oh sure, for array index stuff like that. For general iteration against another number, say, I would use a fixed (or fast) size appropriate to my data.