0

I am currently learning pointers. I am following a book (Says Teach Yourself "Arduino Programming") in which there is an exemple about pointer and array.

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  char string1[] = "This is my test string";
  char string2[]="This is another string test";
  char *ptr2 = string2;
  char *ptr1 = string1;

  while (*ptr1 != '\0') { // not "\0"
    *prt2 = *prt1;
    ptr1++;
    prt2++;
  }
  Serial.println(string1);
  Serial.println(string2);
}

void loop() {
  // put your main code here, to run repeatedly:

}

I get an error "ptr2 was not declare in this scope."

I don't know what is wrong...

That for your help.

1
  • Are you sure the error says ptr2 and not prt2? Commented Nov 22, 2017 at 14:40

1 Answer 1

1

"ptr2" != "prt2"

You have a typo there.

3
  • the classical ptr vs prt, cmd vs cnd, cnt vs cmt, cmt vs cmd and so on... :) Commented Nov 22, 2017 at 14:37
  • It's teh typical typo :) Commented Nov 22, 2017 at 14:38
  • haaa.... Thanks. I have spent 4 days in a row learning Arduino.... I must be tired. thanks again and sorry for such stupid question. it is working just fine now :-) Commented Nov 22, 2017 at 14:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.