CharAt()

My IDE is not recognising the string.charAt command,

It isnt even highlighting when using example code from the arduino site.
I have seen this issue raised before with no clear answer?

String test;


void setup()
{
Serial.begin(9600);
String test = "23456";
}

void loop()
{
char pointer = test.charAt(2);
Serial.print(pointer);
delay(1000);
}

Any help is great thanks

ianmgreen:
My IDE is not recognising

Feel free to elaborate and provide more details.

sorry about that,

The arduino IDE does not highlight the string.charAt() command in orange, and does not act upon it,

im trying to establish whether the code im using is missing something or whether my IDE is setup wrong somehow

Thanks again

Strings are evil. :wink:

char test[] =  "23456";

void setup()
{
   Serial.begin(9600);
}
void loop()
{
  int i=0;
  while (i < strlen(test) )
  {  
     char pointer = test[i++];
     Serial.println(pointer);
     delay(1000);
  }
}

thankyou muchly,

Ill have to alter my code a bit to remove the charat command and add in that bit but you have skipped ahead of me there which is lovely, im making a dialer and that bit of code does exactly what i was going to do in a far simpler manner.

Ta very much

Ian

String test;

A global variable, with no initial value. Useless, but, hey, it's your code.

String test = "23456";

A local variable that immediately goes out of scope. Useless, but, hey, it's your code.

char pointer = test.charAt(2);

The variable named pointer is not a pointer. Lousy choice of names.

What are/were you trying to accomplish?

The variable named pointer is not a pointer. Lousy choice of names.

Agreed, but "hey, it's his code"