`char` — C Keyword

`char` — C Keyword

The char keyword in C: the basic character type, one byte wide.

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.

char (C)

The basic character type, exactly one byte wide (sizeof(char) == 1 by definition). May be signed or unsigned; depends on the implementation.

Syntax

char c;
char c = 'A';
const char* s = "hello";
signed char sc;
unsigned char uc;

Example

#include <stdio.h>
#include <ctype.h>

int main(void) {
    char c = 'H';
    printf("%c  (ASCII %d)\n", c, c);   /* H  (ASCII 72) */

    /* Iterate a C string */
    const char* word = "hello";
    for (int i = 0; word[i] != '\0'; ++i) {
        printf("%c", (char)toupper((unsigned char)word[i]));
    }
    printf("\n");   /* HELLO */
    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;
}