Groovy hepcat DFS was jivin' in comp.lang.c on Wed, 21 Feb 2024 12:07
am. It's a cool scene! Dig it.
> void *memset(void *str, int c, size_t n)
>
> I saw that memset accepts ints where n <= INT_MAX, but above that
Where did you see that? There is no such wording in the standard. From
N3096:
**********************************************************************
7.26.6.1 The memset function
Synopsis
1 #include <string.h>
void *memset(void *s, int c, size_t n);
Description
2 The memset function copies the value of c (converted to an unsigned
char) into each of the first n characters of the object pointed to by
s.
Returns
3 The memset function returns the value of s.
**********************************************************************
I don't think this has changed at all, save section numbering, since the
first version of the standard came out. (Has it, folks?)
And, as you can see, there's no stipulation that n <= INT_MAX. Is this
perhaps a limitation of the implementation you're using?
> requires n to be a size_t (or similar) variable.
> Why does the function definition specify size_t?
Are you kidding? It's the size parameter. Duh! What else would it be
but a size_t? That's what that type is for.
I sometimes use size_t for other things, because it just sort of fits
those uses. But the main purpose of size_t is to represent sizes.
D'ya have any more silly questions, hmm?
--
----- Dig the NEW and IMPROVED news sig!! -----
-------------- Shaggy was here! ---------------
Ain't I'm a dawg!!