I would like to know how to define a char array, in C, of three elements a,b,c
, where a
is located on one first octet, b
in one second and c
in one third.
Asked
Active
Viewed 57 times
-2

Julien
- 91
- 8
-
What is a char tab? Do you mean tab as in table, so an array? – Thomas Jager Apr 02 '19 at 18:39
-
Yes an array, bad translation, sorry. – Julien Apr 02 '19 at 18:44
1 Answers
1
Well, In C, the size of char it's 1. I think we can't know if it's 1 octet or more (or less).
So,
char tab[3] = {'a','b','c'};
doesn't work ?

Clément Truillet
- 32
- 1
- 5
-
I'm pretty sure it can't be less than 1 octet, given that `CHAR_MIN <= -127` and `CHAR_MAX >= 127` ([C11 5.2.4.2.1](http://port70.net/~nsz/c/c11/n1570.html#5.2.4.2.1)). – pmg Apr 02 '19 at 19:08
-
-
See https://stackoverflow.com/questions/9727465/will-a-char-always-always-always-have-8-bits. – Neil Apr 02 '19 at 20:44
-
Viz, `CHAR_BIT` in `limits.h` should tell you. On all POSIX machines, it's 8. – Neil Apr 02 '19 at 20:57