0

I want to know why array and pointers are classified as secondary constants as am reading about constants.

Emil Laine
  • 41,598
  • 9
  • 101
  • 157
  • 4
    What are "secondary constants"? – Emil Laine Dec 23 '15 at 09:49
  • 1
    @zenith: http://www.cprogrambank.com/ctutch2t2 and http://r4r.co.in/c/basic_tutorials/06/CONSTANTS_VARIABLES.shtml – Rahul Tripathi Dec 23 '15 at 09:52
  • This is what I am also looking for@zenith – Harman Randhawa Dec 23 '15 at 09:52
  • 5
    I think that categorisation is as arbitrary as it is unhelpful. The C standard doesn't use the terminology. Why invent more? – Bathsheba Dec 23 '15 at 09:55
  • @HarmanRandhawa:- Its just a categorisation. Why does it matter? – Rahul Tripathi Dec 23 '15 at 09:56
  • @RahulTripathi Anyone have the right to wonder why they split constants into two categories, even if IMO, they just copy terminology from another tutorial and don't know themselves what it means... – Holt Dec 23 '15 at 09:59
  • 3
    Maybe get a better learning material that doesn't use made-up categorizations which they don't even explain? – Emil Laine Dec 23 '15 at 09:59
  • @Holt:- Indeed, but I agree with Bathsheba that its just an aribitrary categorisation which has been done by few sites. Is there any official document you found somewhere? – Rahul Tripathi Dec 23 '15 at 10:00
  • @RahulTripathi No, I totally agree with Bathsheba that this is arbitrary and should not be used except to confuse readers. I was just saying that the OP is not to blame to ask such question, but rather the author of the tutorials. – Holt Dec 23 '15 at 10:01
  • Help me with question that why arrays and pointers are classified in secondry constant although they are not constants@zenith – Harman Randhawa Dec 23 '15 at 10:02
  • 3
    As far as I understand "secondary constants" are those constants whose value are not directly determined by the user but by the compiler or that are determined at run time. But I wouldn't bother about this pretty pointless categorisation. – Jabberwocky Dec 23 '15 at 10:02
  • @HarmanRandhawa if you declare `int array[10]`, then `array` is basically a constant pointer to `int`. There _are_ pointers that are constant, but not _all_ pointers are constant, most of them are not. – Jabberwocky Dec 23 '15 at 10:04
  • @MichaelWalz No, an array is not a pointer. It's an array. – Emil Laine Dec 23 '15 at 14:18
  • @zenith correct, that's why I wrote "...is _basically_ a constant pointer...". Maybe I should have written _more or less_ instead of _basically_. – Jabberwocky Dec 23 '15 at 14:19
  • I don't see how an array is more or less a pointer. An array is a contiguous block of elements of the same type. A pointer contains a memory address. Maybe you're confused by [array-to-pointer decaying](http://stackoverflow.com/q/1461432/3425536) which makes arrays seem like pointers in some contexts? – Emil Laine Dec 23 '15 at 14:50

1 Answers1

2

ISO C standard talks about only 4 types of constants (section §6.4.4)

constant: 
    integer-constant
    floating-constant 
    enumeration-constant 
    character-constant 

There is nothing like primary or secondary constants.

haccks
  • 104,019
  • 25
  • 176
  • 264