In C ‘a’ is an integer constant (!?!), so 4 is correct for your architecture. It is implicitly converted to char for the assignment. sizeof(char) is always 1 by definition. The standard doesn’t say what units 1 is, but it is often bytes.
More Related Contents:
- Are there machines, where sizeof(char) != 1, or at least CHAR_BIT > 8?
- Convert hex string (char []) to int?
- How to convert char to integer in C? [duplicate]
- size of character array and size of character pointer
- Why does strchr take an int for the char to be found?
- In C, why can’t an integer value be assigned to an int* the same way a string value can be assigned to a char*?
- Convert char array to a int number in C
- why sizeof(‘a’) is 4 in C? [duplicate]
- Why is the size of a function in C always 1 byte?
- isnt everything where it should be, why the segmentation fault?
- Logic behind sizeof operator [duplicate]
- returning string in C function [closed]
- Is char signed or unsigned by default?
- Set variable text column width in printf
- What does ‘sizeof (function name)’ return?
- Range of values in C Int and Long 32 – 64 bits
- Difference between unsigned and unsigned int in C
- Behavior of sizeof on variable length arrays (C only)
- unsigned int and signed char comparison
- C: correct usage of strtok_r
- How can I find the number of elements in an array?
- What is the proper way of implementing a good “itoa()” function?
- Getting the size of a malloc only with the returned pointer
- Sizeof arrays and pointers
- How to find the size of an array (from a pointer pointing to the first element array)?
- Hex to char array in C
- How to convert int to float in C?
- C reverse bits in unsigned integer
- Access struct members as if they are a single array?
- Is there any reason not to use fixed width integer types (e.g. uint8_t)?