Save ascii to eeprom - why can not use char array?

Dear friends, please, can you explain me this? Why when i use :

#define PB_NUM_SIZE_ASCII = 5
char pbNum[PB_NUM_SIZE_ASCII]={"hello"}

 Serial.print(pbNum[1]);

this example show e on serial port.

when I want use this :

[code]#define PB_NUM_SIZE_ASCII = 5
char pbNum[PB_NUM_SIZE_ASCII]={"hello"}

byte ii = pbNum[1]; // (i want save this byte to EEPROM)

I get this ERROR : invalid types 'char[int]' for array subscript

I cannot understand why it is error. So char array is sequence of ascii (8bit bytes). Array is used for addressing this sequence. So why when I adressing one byte of this sequence, I cannot use this for store to byte or eeprom for example? I think when I use pointers, it will be working, but why I cannot use this solution in my example?

Many thanks, P.

darksir:

#define PB_NUM_SIZE_ASCII = 5

char pbNum[PB_NUM_SIZE_ASCII]={“hello”}

Serial.print(pbNum[1]);




this example show e on serial port.

No it doesn’t. That code fails to compile for two different reasons. Please take a minute to test your code before posting it to the forum.

define should not have an equals sign.

char pbNum[PB_NUM_SIZE_ASCII]={"hello"}

In addition to the problems already noted, six into five doesn't go.

I'm so sorry. In my sketch is :

define PB_NUM_SIZE_ASCII 12

In my sketch is

That line of code is correct. The problem must be in one of the other lines that you failed to post.

Post the next one, and we’ll analyze that one. Shouldn’t take more than a couple of weeks, looking at one line at a time to get to the root of the problem.

Sorry boys, I found my mistake. I used this in function :

bool PBsaveNum (int pbId, char pbNum) {
byte a=pbNum[1];
 .....}

I am absolutely stupid :-) I have declare pbNum char array as public variable. So i don't need put this variable as parameter to function. In my case I rewrite pbNum[12] array with one char pbNum. So this is that reason for why use of pbNum[1...12] in my function give ERROR.

I am absolutely stupid

Can't really help you with that problem. 8)

PaulS: Shouldn't take more than a couple of weeks, looking at one line at a time to get to the root of the problem.

Is trolling your part time job?

cyberjupiter: Is trolling your part time job?

I prefer to think of it as humorous prodding to initiate thinking.

cyberjupiter: Is trolling your part time job?

No. Computer programming is my part time job. Trolling is my full time job.

AWOL: I prefer to think of it as humorous prodding to initiate thinking.

Unless that "humour" is almost in every thread.

cyberjupiter: Unless that "humour" is almost in every thread.

So is your (programming) issue resolved now?

(deleted)