i want to return 2 values but i don't know how i can do that. this is part of what i have done, i want to have choice[0] and also choice[1] be returned. also how can i store them in 2 different variables in the main.

int pick()
{
 choice1=wake();
 do
 {
 switch (choice1)
 {
 case 2:
	 homework();
	 choice[0]=2;
	 c=2;
  break;
 case 3: 
	 choice[1]=sleep();
	 choice1=choice[1];
	 choice[0]=3;
	 c++;
	 break;
 case 1:
	choice[1]=wander();
	 choice[0]=1;
	 c=2;
  break;
 default:
	 cout<<"Ha Ha Ha Ha Ha"<<endl;
	 c++;
	 break;
 }
 }
 while(c<2);
 return choice[0];
}

int main()
{
 choice[0]=pick();
 return 0;
}

Your code make no sense. You didn't declare choice[] and choice1 anywhere, how can you use those variable? You cannot return 2 values, but you can return in array.

i said that this was part of my code, it works but i just wanted to know how to return 2 values, how can i return in array

pass the array as a parameter

int pick(int choice[])
{

}
int pick()
{
 choice1=wake();
 do {
   ........
   .......
  }
 }
 while(c<2);
 [B]return choice[0];[/B]
}

int main()
{
 [B]choice[0]=pick();[/B]
 return 0;
}

First, you didn't declare the choice[] in the function pick(), so choice[] must be declare globally. so if you make change the choice[] in the function, it affect globally. So what's the point of return?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.