![]() |
Motor drive function?
Lets say I want to have a function, that somehow modifies an inputted speed and sets an inputted motor to that speed. Instinct tells me it would be something similar to
Code:
void Drive(int motor, unsigned char speed)What is the cause of this problem? How can I fix it? |
Re: Motor drive function?
You need to pass the parameter that will be changed in by address rather than value.
Code:
void Drive(int *motor, unsigned char speed) |
Re: Motor drive function?
Quote:
I think that you are mixing C++ with C. in C++, "int&" is a pass by reference. In C there is no pass by reference only pass by value and a pointer is the only way to do it. Mike To All, Mark's post is correct. Please read K&R chapter 5 before sliding down the perilous and provocative path of pointers. Mike |
Re: Motor drive function?
Quote:
|
| All times are GMT -5. The time now is 18:13. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi