I'm playing with pointers and would like to print the value of the pointer (the actual address stored in the pointer variable) and not the value at that address. I get a cascade of compiler errors which amount to incorrect variable type passed to Serial.print()
I'm using IDE 2.3.2
Is there a different way I should display an address?
void setup() {
int i = 25;
int* iPoint;
Serial.begin (9600);
iPoint = &i; // set the pointer to the address of i
Serial.print(iPoint); // try to print the address of i
}
void loop() {
}
--------------- RESULTING COMPILE ERRORS
C:\Users\glenn\AppData\Local\Temp\.arduinoIDE-unsaved2024311-9316-8f90x3.uf3r5\sketch_apr11b\sketch_apr11b.ino: In function 'void setup()':
C:\Users\glenn\AppData\Local\Temp\.arduinoIDE-unsaved2024311-9316-8f90x3.uf3r5\sketch_apr11b\sketch_apr11b.ino:6:22: error: no matching function for call to 'print(int*&)'
Serial.print(iPoint); // tru to print the address of i
^
In file included from C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Stream.h:26:0,
from C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:29,
from C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:233,
from C:\Users\glenn\AppData\Local\Temp\arduino\sketches\14ACC17B2B01198D0AFD85BA88983E62\sketch\sketch_apr11b.ino.cpp:1:
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:68:12: note: candidate: size_t Print::print(char) <near match>
size_t print(char);
^~~~~
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:68:12: note: conversion of argument 1 would be ill-formed:
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:69:12: note: candidate: size_t Print::print(unsigned char, int) <near match>
size_t print(unsigned char, int = DEC);
^~~~~
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:69:12: note: conversion of argument 1 would be ill-formed:
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:70:12: note: candidate: size_t Print::print(int, int) <near match>
size_t print(int, int = DEC);
^~~~~
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:70:12: note: conversion of argument 1 would be ill-formed:
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:71:12: note: candidate: size_t Print::print(unsigned int, int) <near match>
size_t print(unsigned int, int = DEC);
^~~~~
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:71:12: note: conversion of argument 1 would be ill-formed:
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:72:12: note: candidate: size_t Print::print(long int, int) <near match>
size_t print(long, int = DEC);
^~~~~
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:72:12: note: conversion of argument 1 would be ill-formed:
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:73:12: note: candidate: size_t Print::print(long unsigned int, int) <near match>
size_t print(unsigned long, int = DEC);
^~~~~
C:\Users\glenn\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Print.h:73:12: note: conversion of argument 1 would be ill-formed:
exit status 1
Compilation error: no matching function for call to 'print(int*&)'
