Reputation: 1453
I saw this in Apple's framework files
enum
{
kAudioFormatLinearPCM = 'lpcm',
kAudioFormatAC3 = 'ac-3'
}
What is the type of 'lpcm'
and 'ac-3'
?
With a single character in the single quote like this '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.
Upvotes: 2
Views: 125
Reputation: 370152
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'
.
Upvotes: 3
Reputation: 1726
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?
Upvotes: 4