Sujet : Re: size_t best practice
De : mark (at) *nospam* qtrac.eu (Mark Summerfield)
Groupes : comp.lang.cDate : 18. Aug 2024, 11:15:52
Autres entêtes
Message-ID : <yK-cnTtFMYNFVFz7nZ2dnZfqnPudnZ2d@brightview.co.uk>
References : 1 2
User-Agent : Pan/0.149 (Bellevue; 4c157ba)
On Sun, 18 Aug 2024 08:38:13 -0000 (UTC), Ike Naar wrote:
[snip]
Substitution: j = i + 1
for (size_t j = v->_size; j > index; --j) {
v->_values[j] = v->_values[j - 1];
}
Thanks, that works great.
And as per "Michael S" I checked the man pages:
ptrdiff_t Used for a count of elements, and array indices. C99 and POSIX.1-2001.
size_t Used for a count of bytes. C99 and POSIX.1-2001.
ssize_t Used for a count of bytes or an error indication. POSIX.1-2001.
So for my arrays and loops I'll change to ptrdiff_t.