ROBOTC.net forums
http://robotc.net/forums/

multiple parameters in a function?
http://robotc.net/forums/viewtopic.php?f=11&t=7182
Page 1 of 1

Author:  Stevenc [ Mon Nov 04, 2013 1:39 pm ]
Post subject:  multiple parameters in a function?

what i currently have:

Code:
void forward(int s)
{
   motor[rightMotor] = s;
   motor[leftMotor] = s;
   wait(0);
}


I'd like to set it up as something like:

Code:
void forward(int s, d)
{
   motor[rightMotor] = s;
   motor[leftMotor] = s;
   wait(d);
}

and be able to use a function such as forward(100, 50); and move forward with motors at a value of 100 for 50mSecs.
How would i set this up?

Author:  MHTS [ Mon Nov 04, 2013 4:10 pm ]
Post subject:  Re: multiple parameters in a function?

Code:
void forward(int s, int d)
{
   motor[rightMotor] = s;
   motor[leftMotor] = s;
   wait(d);
}

You need to specify the data type of each of the parameters.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/