View unanswered posts | View active topics It is currently Mon Oct 20, 2014 10:17 pm






Reply to topic  [ 2 posts ] 
multiple parameters in a function? 
Author Message
Rookie

Joined: Mon Nov 04, 2013 1:34 pm
Posts: 1
Post 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?


Mon Nov 04, 2013 1:39 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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.


Mon Nov 04, 2013 4:10 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.