issues with words in strings in array

So I am super stuck been at this for hours now…

#define MAXrelay 5
char* relayUse[] = {"test","cat","fish","bird","tree","lemon"};
 for (int i = 1; i <= MAXrelay; ++i)
//for i loop code truncated for ease of reading..
 Serial.print(i-1);
 Serial.println(relayUse[i-1]);

returns the following

0?Content-Length:
1?Content-Length:
2?Content-Length:
3?Content-Length:
4tree

I am at a total loss as to why index 0 and 1 normally are bad or wrong the Content-Length:, I assume index 2-3 are messed up because of 0, if I prevent index 0 from being returned it will give different data.

It's hard to tell from your snippet, but it looks like you are missing braces.

{ and }

The "if" only affects the next statement without them.

Also, arrays start at 0 in C, not at 1.

[quote author=Nick Gammon link=topic=181005.msg1341619#msg1341619 date=1375602805] Also, arrays start at 0 in C, not at 1. /quote

That piece of code as it stands is completely useless. Can you post a piece of code that compiles and demonstrates the problem? I suspect that in creating such a piece of code you will find that the problem is not reproducible.

My guess is that the problem is actually somewhere completely different. You have some bit of code overwriting your array - usually because you are extending past the end of some other array that is defined previously.

You have some bit of code overwriting your array - usually because you are extending past the end of some other array that is defined previously.

that was exactly what was happening - thanks for helping my brain.