Compiler error when printing array

This little sketch snippet creates an error. What am I doing so wrong?

Sketch code:

#include <OneWire.h>
#include <DallasTemperature.h>

DeviceAddress DevAddr[8];

void setup()
{
  int i = 3;
  Serial.begin(9600);
  Serial.print(DevAddr[i]);
}

void loop ()
{}

Error ouput:

E:\Documents\Arduino\sketch_feb10b\sketch_feb10b.ino: In function 'void setup()':
sketch_feb10b:10:26: error: no matching function for call to 'print(DeviceAddress)'
   Serial.print(DevAddr[i]);
                          ^
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,
                 from sketch\sketch_feb10b.ino.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:66:12: note: candidate: size_t Print::print(const String&) <near match>
     size_t print(const String &);
            ^~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:66:12: note:   conversion of argument 1 would be ill-formed:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:67:12: note: candidate: size_t Print::print(const char*) <near match>
     size_t print(const char[]);
            ^~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:67:12: note:   conversion of argument 1 would be ill-formed:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:68:12: note: candidate: size_t Print::print(char) <near match>
     size_t print(char);
            ^~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:68:12: note:   conversion of argument 1 would be ill-formed:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:69:12: note: candidate: size_t Print::print(unsigned char, int) <near match>
     size_t print(unsigned char, int = DEC);
            ^~~~~

DeviceAddress is itself an array. You will need to print the eight bytes in it one at a time.

Thanks wildbill :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.