Advertisement

2D array

Started by April 25, 2022 11:39 PM
1 comment, last by Tom Sloper 2 years, 7 months 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;
	}
}
                                                                                               

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