there are four playing cards . you choose one of them
if selected card is 1 spades you win else you lose
but ı want to make win card as random from 4 cards. i dont know how.

``````#include <cstdlib>
#include <iostream>

using namespace std;
const int clubs=0;
const int diamonds=1;
const int hearts=2;
const int spades=3;
int position;

struct pcards

{
int numb; // numbers change from 1 to 9
int suits;   // change from 0 to
};

int main(int argc, char *argv[])
{
string dec;
int basa;
pcards selected,win;
pcards card_one= {4,diamonds};
pcards card_two= {8,clubs};
pcards card_three= {1,spades};
pcards card_four= {7,hearts};
win=card_three; // I choose ace spades
basa:
cout << " pls tell me which position does   1,spades there 1-2-3-4 \n";
cin>> position;
switch (position)
{
case 1 : selected=card_one ;break;
case 2 :selected=card_two ;break;
case 3 :selected=card_three ;break;
case 4 : selected=card_four ;break;

}
if (selected.suits==win.suits && selected.numb==win.numb)
cout <<  "you win... you find it \n";
else
cout << "you lose next time \n";
cout << " do you want to play again y/n ?";
cin >> dec;
if (dec=="Y" || dec=="y") goto basa;
else
cout << "bye";

system("PAUSE");
return EXIT_SUCCESS;
}``````

Use an array for the 4 cards. Get a random number from 0-3. This will be an index into that array to point to the win card.

if i create array for the card under the struct
conflicting declaration
pcards card_name[0]= {4,diamonds};
win=card_name[rand() % 4];
soory i am not good at

I solved the problem with switch case ... I generate x with random
switch (x) and case ... I put win=card_one, and so on

I dont know two dimensional array with string.