View unanswered posts | View active topics It is currently Mon Oct 20, 2014 5:50 am






Reply to topic  [ 3 posts ] 
I need Help. about vectores 
Author Message
Rookie

Joined: Tue Sep 01, 2009 7:09 am
Posts: 1
Post I need Help. about vectores
i have a problem. in robot c and i don't know how to resolve it.
i want to send a vector to a function in robot c. i get a lot of error.
do you now a way to resolve???

sample of program:

int estadoPartida[9];

int npessoas(int estadoCorrente[])
{
int n=0;
int i;
for (i=1;i<=8;i++)
{
if ( estadoCorrente[i]>0)
n++;
}

return n;
}


task main()
{
int np;
np = npessoas(estadoPartida);
}


Tue Sep 01, 2009 10:30 am
Profile
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: I need Help. about vectores
Solutions for this problem have been posted on this forum before. Search for: passing arrays to functions.

_________________
My most recent blog: A grain of sugar


Thu Sep 03, 2009 5:49 pm
Profile WWW
Rookie

Joined: Fri Sep 11, 2009 9:22 am
Posts: 1
Post Re: I need Help. about vectores
I'm just learning robotC, but this seems like a regular C question. Your array does not need to be passed between these two functions because of where you declared it. Simply:

int estadoPartida[9];

int npessoas( )
{
int n=0;
int i;
for (i=1;i<=8;i++)
{
if ( estadoPartida[i]>0) // same array as in main
n++;
}

}

and

task main()
{
int np;
np = npessoas();
}


Fri Sep 11, 2009 9:32 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: Kern5566 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.