2

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.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Li Fumin
  • 1,383
  • 2
  • 15
  • 31

2 Answers2

4

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?

Community
  • 1
  • 1
Adam Magaluk
  • 1,716
  • 20
  • 29
3

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'.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • Thanks, seems like it is called integer character constant.Programmming books rarely mention this, it is odd. – Li Fumin Aug 21 '11 at 16:09