Hello again everyone :), this is a program for my class that is just a simple card game. I am experiencing a crash or "Segmentation fault" and I have narrowed it down to line 148 with some couts and I cant figure it out.
Thanks guys, please keep in mind this is still a work in progress :)
Thanks for the response but that didn't work, it seems even after I changed that and made the subscripts from 0 to 1 not from 1 to 2 it is still crashing and now I have narrowed it down to line 23 or 24 its crashing while its declaring?
actually yes I did, i didn't upload the new code though didn't have time this morning :P sorry, also I figured out what it was and it was actually my logic in my main function!
Thanks for all the help :)
Rawr
not sure why you declare Player* p like that when u just as might could allocate on the stack
1 2
Player p;
Player c;
then when passing to your functions, declare them pass by reference
Suddah(Player& p, Player& c, Deck d1)
Avoid passing pointers if you don't really need to because you then normally need check the pointers since if somebody else one day uses your function and passes NULL it will crash. With reference you can be sure that you get the objects.
note also that you are passing a copy of d1, not the actual d1 so any changes to d1 in your function are done on a copy of the original and not given to the caller.
Suddah(Player& p, Player& c, Deck &d1)
otoh would make a difference when you modify d1.numberofCards after you modify the statement
Line 192: You have an opening brace for no reason.
Line 193: You have no opening brace here, so Player *p is only ever allocated if reponse = 'n'. If response is something else this will cause a crash in the suddah function on line 152.
Line 23/24: Index should start at 0/1 not 1/2
When allocating you should do.
1 2 3 4 5
Player* p = 0;
p = new player();
if (p != 0)
delete p;