`unsigned` — C Keyword
`unsigned` — C Keyword
The unsigned keyword in C: marks an integer type as unsigned (non-negative only).
`unsigned` — C Keyword
The unsigned keyword in C: marks an integer type as unsigned (non-negative only).
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
unsigned (C)Marks an integer type as unsigned: values range from 0 to $2^N - 1$. Unsigned arithmetic wraps modulo $2^N$ (well-defined).
unsigned char uc;
unsigned short us;
unsigned int u; /* 'int' is optional */
unsigned long ul;
unsigned long long ull;
#include <stdio.h>
#include <limits.h>
int main(void) {
unsigned int u = UINT_MAX;
printf("%u\n", u); /* 4294967295 (on 32-bit int) */
/* Well-defined wrap */
unsigned char uc = 255;
++uc;
printf("%u\n", uc); /* 0 */
/* Sizes and counts should be unsigned */
unsigned int len = 10;
for (unsigned int i = 0; i < len; ++i) {
/* use i ... */
}
return 0;
}
size_t (from <stddef.h>) for sizes and object counts.int main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}