🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

2D array

Started by
1 comment, last by Tom Sloper 2 years, 1 month ago

I am trying to print out a 5X8 grid of characters from A to U in pairs just like

SHIENULD

SKULDEIN

etc..

here is my code

void Memory::fillBoard()
{
	srand(time(NULL));
	int symbol = 0;
	char cards_two[4][5];
	int randcards[21];
	for (int i = 65; i < 86; i++)
	{
		randcards[i-65] = i;
	}
	char cards[21];
	for (int i = 0; i < 20; i++)
	{
		symbol = i + rand() % (20 - i);
		cards[i] = randcards[symbol];
		randcards[symbol] = randcards[i];
	}
	for (int x = 0; x < 4; x++)
	{
		for (int k = 0; k < 5; k++)
		{
			cards_two[x][k] = cards[x * 5 + k];
			cout << cards_two[x][k] << " ";
		}
		cout << endl;
	}
}
                                                                                               
Advertisement

Good to know that your tank is apparently now moving properly, Phil. You're not asking a question here, so this thread is locked. If you just want to share code, use Blogs (see left sidebar) or the Your Announcements forum.

-- Tom Sloper -- sloperama.com

This topic is closed to new replies.

Advertisement