What is the type of a '1'
constant in C? Before any promotions. Is it a char
or an int
?
Asked
Active
Viewed 50 times
0

Ron
- 14,674
- 4
- 34
- 47
-
`1` is `int`, `'1'` is `int` too. – pmg Sep 04 '20 at 11:30
-
In C chars are ascii ints – georgeok Sep 04 '20 at 11:32
-
@pmg The dupe is spot on. Appreciate it. – Ron Sep 04 '20 at 11:39
-
2To actually answer _why_, it probably got to do with C not having much in the way of a type system back in the days, so they treated everything as `int`. – Lundin Sep 04 '20 at 11:57