Splitting a deck

Pages: 12
i gave it a value of 52.

I hope you don't mean string cards="52";

Now when I run it it just says. "Press any key to continue"

Well, duh. What did you expect to happen?
You don't "give it a value of 52", you actually make it 52 characters long:
cards = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop";
Its saying srand, random_shuffle, and system are "ambiguous".. And its still saying "press any key to continue"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "main.h"
#include <ctime>
#include <string>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <time.h>
using namespace std;


int main()
{

	string cards = "h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h12, h13, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13";
	srand(time(NULL));
	random_shuffle(&cards[0],&cards[52]);
	system("PAUSE");
	return 0;

}
You're far in over your head on this one.
You should continue reading your C++ book and then come back to this later.
I agree. haha, i just took out the Letters, and ran it. Worked fine, now that I think about it if the letters wouldve been pointed out in char earlier it probably wouldve worked.. But im too tired for this, haha.
Firstly, you never tell it to print anything, so what do you expect it to say? Well, your system("PAUSE"); instead of cin.sync(); cin.ignore(); pretty much does all the output.

Second, shuffling the string from 0 to 51 only changes the order of these characters:
h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h
and leaves the rest of the letters alone.

Thirdly, you have two h12 right off the bat, hopefully yo will be thinking better after sleep ;)

Fourth, including <ctime> automatically includes <time.h>, so there's no need to double-up. Mos of the includes you included are unrelated to your program, so I'm not sure why you included them.

Also, it's uncommon to use a Main.h header and include stuff in it, it's more common to just put the includes directly in Main.cpp
Last edited on
Topic archived. No new replies allowed.
Pages: 12