array decay

M

Mantorok Redgormor

array doesn't decay when operand of sizeof, or & or when the array is
a string or wide-string literal initializer.

I understand the first two, but the thing about being used as an
initializer means what? can someone give an example?


- nethlek
 
K

Kevin Bracey

array doesn't decay when operand of sizeof, or & or when the array is
a string or wide-string literal initializer.

I understand the first two, but the thing about being used as an
initializer means what? can someone give an example?

It's talking specifically about string literals (which you may not realise
are actually of array type), when used to initialise an array. Example:

char a[20] = "Hello";

I'm not quite sure why the standard feels the need to say that, as I thought
such an initialiser was a special case anyway. I can't say I ever viewed it
as an actual assignment of one array to another; I just thought of it as a
specially recognised syntactical form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top