Skip to main content
rewrite question for more clarity
Source Link
guyd
  • 1k
  • 2
  • 26
  • 62

How to define and accessuse a list/array of chars using `Serial.print`

I wish to define a list of months names and access it when printing a report.

When using Python- it is easy

months=['Jan','Feb','Mar'] ,and months[i] yields Jan.

Since I'm new to Arduino - I try to define and access this list without any success.Array was defined as follows:

const char months []= {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};

for (int i=0; i<=11; i++) {

                                 Serial.print(months[i]);
                        }

Tries:

I was looking for help under Arrays in arduinoArduino documentation didn't give, as far as I found, any explanation for such case., but arrays of int

Appreciate any help.

How to define and access a list/array of chars

I wish to define a list of months names and access it when printing a report.

When using Python- it is easy

months=['Jan','Feb','Mar'] ,and months[i] yields Jan.

Since I'm new to Arduino - I try to define and access this list without any success.

const char months []= {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};

for (int i=0; i<=11; i++) {

                                 Serial.print(months[i]);
                        }

looking for help under Arrays in arduino documentation didn't give, as far as I found, any explanation for such case.

Appreciate any help.

How to define and use a list/array of chars using `Serial.print`

I wish to define a list of months names and access it when printing a report.

Array was defined as follows:

const char months []= {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};

for (int i=0; i<=11; i++) {

                                 Serial.print(months[i]);
                        }

Tries:

I was looking for help under Arrays in Arduino documentation didn't give, as far as I found, any explanation for such case, but arrays of int

Appreciate any help.

Post Closed as "Not suitable for this site" by Juraj, sempaiscuba, gre_gor, per1234, Greenonline
Source Link
guyd
  • 1k
  • 2
  • 26
  • 62

How to define and access a list/array of chars

I wish to define a list of months names and access it when printing a report.

When using Python- it is easy

months=['Jan','Feb','Mar'] ,and months[i] yields Jan.

Since I'm new to Arduino - I try to define and access this list without any success.

const char months []= {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};

for (int i=0; i<=11; i++) {

                                 Serial.print(months[i]);
                        }

looking for help under Arrays in arduino documentation didn't give, as far as I found, any explanation for such case.

Appreciate any help.