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:00CommentedNov 22, 2017 at 14:40
1 Answer1
"ptr2" != "prt2"
You have a typo there.
- 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:00CommentedNov 22, 2017 at 14:37
- 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:00CommentedNov 22, 2017 at 14:39
Explore related questions
See similar questions with these tags.