Organizing playing Cards into Stacks by the Cards Figure

I am reading the cards that are being generated in Deck.h. I am fairly new to this and I have to organize the cards into stacks by their figures, being either hearts, diamonds, spades or clubs. Any Help or comments on this code will be appreciates.

***The program generates correctly and does all functions well. As soon as I add this code to the proyect, it does not run, so I am guessing there is something wrong here.*** Thanks!


#include"stdafx.h"
#include"Deck.h"
#include"Card.h"
#include"DStack.h"


int main ()
{
Deck *A = new Deck();
A->Generate(52);
Stack<Card> stk_d, stk_c, stk_t, stk_e;
Card *TempC = new Card();
char c,d,t,e;
int i;
int x=A->size();

//The letters(c,d,t,e) are the cards figure, while the number resembles the figure in ASCII Code


c=3;//c=hearts
d=4;//d=diamond
t=5;//t=clubs
e=6;//e=spades
for(i=0; i<x; i++)
{
delete[] TempC;
TempC = new Card((*A)[i]);
if(TempC.Symbol==d)
{

stk_d.push(A->pop(i));
}//endif

else
{
if(TempC.Symbol=c)
{
stk_c.push(A->pop(i));

}

}//endelse

else
{
if(TempC.Symbol=t)
{

stk_t.push(A->pop(i));
}//endif
}//endelse
else
{

if(TempC.Symbol=e)
{
stk_e.push(A->pop(i));


}//endif
}//endelse

}//endfor
First things first: use code tags.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include"stdafx.h"
#include"Deck.h"
#include"Card.h"
#include"DStack.h"


int main ()
{
Deck *A = new Deck();
A->Generate(52);
Stack<Card> stk_d, stk_c, stk_t, stk_e;
Card *TempC = new Card();
char c,d,t,e;
int i;
int x=A->size();

//The letters(c,d,t,e) are the cards figure, while the number resembles the figure in ASCII Code


c=3;//c=hearts
d=4;//d=diamond
t=5;//t=clubs
e=6;//e=spades
for(i=0; i<x; i++)
{
delete[] TempC;
TempC = new Card((*A)[i]);
if(TempC.Symbol==d)
{

stk_d.push(A->pop(i)); 
}//endif

else
{
if(TempC.Symbol=c)
{
stk_c.push(A->pop(i)); 

}

}//endelse

else
{
if(TempC.Symbol=t)
{

stk_t.push(A->pop(i));
}//endif
}//endelse
else
{

if(TempC.Symbol=e)
{
stk_e.push(A->pop(i));


}//endif
}//endelse

}//endfor 


Second: Can you be a bit more specific about what's wrong? What error are you getting? Can you go through the code with F10 and find where it breaks? These things make it easier for us to locate what the problem is and help you.
Topic archived. No new replies allowed.