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.
-
Are you sure the error says ptr2 and not prt2?gre_gor– gre_gor2017年11月22日 14:40:52 +00:00Commented Nov 22, 2017 at 14:40
1 Answer 1
"ptr2" != "prt2"
You have a typo there.
answered Nov 22, 2017 at 14:35
-
the classical ptr vs prt, cmd vs cnd, cnt vs cmt, cmt vs cmd and so on... :)Peter– Peter2017年11月22日 14:37:56 +00:00Commented Nov 22, 2017 at 14:37
-
It's teh typical typo :)Majenko– Majenko2017年11月22日 14:38:18 +00:00Commented 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– Max2017年11月22日 14:39:53 +00:00Commented Nov 22, 2017 at 14:39