12 years, 5 months ago.

pointers

Hi i get faults messages with my pointers:

int main...

while(leesregister(0x00) != '0');   //function call



char leesregister(char adres)           //we get the adres of a register and we want to send back the value in that register
{
char terugstuurwaarde;              //this is the name of the variable we want to send back
i2c.write(addr, *adres, 1, 0);
i2c.read(addr, *terugstuurwaarde, 1, 0);
return terugstuurwaarde;

i know i have to use pointers when i use i2c.write/read functions but he doesnt want to except this, how come, i dont understand how it can. thank you in advance adriaan

"operand of "*" must be a pointer" in file "/main.cpp", Line: 10, Col: 17

"operand of "*" must be a pointer" in file "/main.cpp", Line: 11, Col: 17

1 Answer

12 years, 5 months ago.

Assuming adres and terugstuurwaarde are just regular chars, you are using the wrong modifier: '*' gives the value of whatever a pointer points to, '&' is the one you need, that gives the pointer to the variable.

Accepted Answer

thnx! your right indeed, somewhere far i knew it, it is a long time ago i programmed in c, and i have to refresh it all, thnx again

posted by Adriaan Van Steendam 16 Mar 2013