Skip to main content
edited tags
Link
user31481
user31481
added 90 characters in body
Source Link
Majenko
  • 105.9k
  • 5
  • 82
  • 139

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:

}`

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.

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.

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.

Source Link
Max
  • 13
  • 1

Error with pointer in array

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.