I'm working on a game. It has to generate two (actually more then two, hence the function) bridges at any given time randomly and they can not be at the same location.
How do I call br1 and br2 from my function into my main program? I want to make br1 = br1top and br2 = br2top. The function can only run one time. I don't really want to split it into two functions because I'm sure there is a way to do this.
This is what I have but its not working. It compiles, but I'm not sure of the syntax to get this to work. The integers are not coming back correctly for me.
#include <stdio.h>
int bridgefunc (int br1, int br2);
int main ()
{
int br1top, br2top;
//Set bridge startpoints. 2 per side.
bridgefunc(br1top,br2top);
printf ("br1 = %i\n",br1top);
printf ("br2 = %i\n",br2top);
system ("pause");
return 0;
}
int bridgefunc (int br1, int br2)
{
int i;
//find bridge location points via random numbers
for (i=0;i<90000000;i++)
{} //delay for loop to make numbers from time more random.
br1=rand()%6;
printf ("function br1 = %i \n",br1); //debug
br2=br1;
printf ("function br2 = %i \n",br2); //debug
//ensures br1 does not equal br2.
while (br2==br1)
{
for (i=0;i<90000000;i++)
{} //delay for loop to make numbers from time more random.
br2=rand()%6;
printf ("function br2 = %i \n",br2); //debug
}
return (br1, br2);
}