Arduino nano code to arduino nano every code

Pointers are not needed, or wanted, here.

If it compiled without error, that would have given some very bizarre results!

encLeftValue and encRightValue are long int variables. They are not pointers. If you try to treat them as pointers, you can accidentally overwrite RAM memory at "random" locations, causing weird corruption of memory belonging to other variables.

Imagine you have a friend who's birthday is coming soon. He will be 23 years old and you want to send a birthday card to him. He lives at 27, Canal Street. Do you send the card to 23 Canal Street? Of course you don't. Some random person you don't know will receive the card. That's what happens when you mix up a value with the address where that value resides.

ok, thank you very much !

In other words "please go away now, you're scaring me". I'm sorry, that was not intention. Sorry if I appeared condescending. I genuinely want you to understand, it's an important thing but but not easy to grasp at first.

If you change your mind, just let me know.

No, the problem is that i didn't think before writing my question about the pointers...

encLeftValue and encRightValue are attributs of the class encoder_driver so it's okay to call a function of a class that change the value of an attributs of this class.

I believed that this function was used in a main and encLeftValue was declared in the main

1 Like

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