This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

size_t

Prototype

#include <stddef.h>

typedef implementation-defined size_t;

Description

The size_t type is the unsigned integral type of the result of the sizeof operator. It is widely used in the standard C library for declaring size parameters, for example:
void *memcpy(void *dest, const void *src, size_t n);
size_t strlen(const char *s);
char *strncat(char *dest, const char *src, size_t n);

Example

View source
#include <stddef.h>

/*
 * Truncate the argument string to maximum `n' characters.
 */
char *strtrunc(char *s, size_t n)
{
    char *sp;
    for (sp = s; *sp != '\0'; ++sp)
	if (sp - s >= n) {
	    *sp = '\0';
	    break;
	}
    return s;
}

References

ISO C 9899:1990 7.1.6