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?
    – gre_gor
    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... :)
    – Peter
    Nov 22, 2017 at 14:37
  • It's teh typical typo :)
    – Majenko
    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 :-)
    – Max
    Nov 22, 2017 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.