How do Arrays work?

I admit my mistake and went back and corrected it with credit to GolamMostafa.

UKHeliBob:
Which works :slight_smile:

Jeez - that will really confuse folk :slight_smile:

...R

UKHeliBob:
I expect that you meant

char h = 'h';

char e = 'e';
char l = 'l';
char o = 'o';
char characters = {h, e, l, l, o};




Which works :)

This is a new style of declaring an array; so, it is enjoyable. We have seen the following styles:

char characters[] = {'h', 'e', 'l', 'l', 'o'};
char characters[] = "hello";
char characters[] = {0x68, 0x65, 0x6C, 0x6C, 0x6F};  //direct ASCII codes

You forgotchar characters[] {'h', 'e', 'l', 'l', 'o'};

AWOL:
You forgot

char characters[] {'h', 'e', 'l', 'l', 'o'};

I have learnt two things (upto now) from this thread --

A post is targeted to the immediate previous poster if no specific poster is mentioned.

An array can be initialized/declared/defined this way:

char characters[] {'h', 'e', 'l', 'l', 'o'};.

Robin2:
Jeez - that will really confuse folk :slight_smile:

…R

Probably, but it does prove that groundFungus’s declaration code, although incomplete, would have worked :slight_smile:

We have seen the following styles:

char characters[] = {'h', 'e', 'l', 'l', 'o'};

char characters = "hello";
char characters = {0x68, 0x65, 0x6C, 0x6C, 0x6F};  //direct ASCII codes

Note that not all of those declarations result in the same array

AWOL:
More homework questions...

From a sock puppet.

(Other account restored. It's been more than a month.)

Thank you moderator, Very cool!