`signed` — C Keyword

`signed` — C Keyword

The signed keyword in C: explicitly marks an integer type as signed.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

signed (C)

Explicitly marks an integer type as signed. Redundant for int, short, long, and long long (they are signed by default), but meaningful for char whose signedness is implementation-defined.

Syntax

signed char sc;
signed short ss;
signed int   si;
signed long  sl;

Example

#include <stdio.h>

int main(void) {
    signed char sc = -42;
    signed int  si = -1000;

    printf("%d\n", sc);   /* -42 */
    printf("%d\n", si);   /* -1000 */

    /* Contrast: unsigned char wraps */
    unsigned char uc = (unsigned char)(-1);
    printf("%u\n", uc);   /* 255 */
    return 0;
}

Notes

Example in practice

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;
}