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.

askedNov 22, 2017 at 14:33
Max's user avatar
1
  • Are you sure the error says ptr2 and not prt2?CommentedNov 22, 2017 at 14:40

1 Answer1

1

"ptr2" != "prt2"

You have a typo there.

answeredNov 22, 2017 at 14:35
Majenko's user avatar
3
  • the classical ptr vs prt, cmd vs cnd, cnt vs cmt, cmt vs cmd and so on... :)CommentedNov 22, 2017 at 14:37
  • It's teh typical typo :)CommentedNov 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 :-)CommentedNov 22, 2017 at 14:39

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.