unsigned char ascii; int a = 0; char string[4] ="foo"; "A1" ascii = (string[a] - 'A' + 10) * 16;
warning: conversion to ‘unsigned char’
from ‘int’ may alter its value
It seems that gcc considers chars and number literals as int by default. I know I could just cast the expression to (unsigned char) but how can I specify char literals and number literals as 8 bit without casts ?
A similar issue:
Literal fractions are considered double by default but they can be specified to float by:
3.1f
Therefore, 3.1 would be considered a float rather than a double.
In
C, you cannot do calculations in anything shorter thanint