I saw this in Apple's framework files
enum
{
kAudioFormatLinearPCM = 'lpcm',
kAudioFormatAC3 = 'ac-3'
}
What is the开发者_JAVA百科 type of 'lpcm'
and 'ac-3'
?
'a'
, I know it is a char; With double quotes like this "text"
, I know it is a string.
But this? This makes me confused.
Well first your in a type enum so it can only represent a int. I think apple using it to create unique vals for the enum but also wants it human readable.
For a much better explanation see: What is the type of an enum whose values appear to be strings?
Contrary to popular belief the type of 'c'
in C is int
, not char
. When you do something like char c = 'c';
, there will be an implicit conversion from int
to char
, same as if you had written char c = 99;
.
So to answer your question: the type of 'abcd'
is int
, same as the type of 'c'
.
精彩评论