Compiler Error.

Apparently, I've been on away for too long. I can't even solve a simple compiler error.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

const int number_of_cards = 52;

int main() {
	string deck[number_of_cards] = {};
	string suits[] = {"Clubs", "Diamonds", "Hearts", "Spades"};
	string ranks[] = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
	//int value[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

	int index;
	for(int x = 0; x < 4; x++) {
		for(int i = 0; i < 13; i++) {
			deck[index++] = ranks[i] + " of " + suits[x];
		}
	}

	for(int x = 0; x < number_of_cards; x++)
		cout << deck[x] << endl;
	return 0;
}


Compiler: Visual C++ 2008
http://i158.photobucket.com/albums/t102/renji71/compilererror.jpg
'idelcarewar.exe': Loaded 'C:\Documents and Settings\Angel\Desktop\idelcarewar\Debug\idelcarewar.exe', Symbols loaded.
'idelcarewar.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'idelcarewar.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'idelcarewar.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll'
'idelcarewar.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
Run-Time Check Failure #3 - The variable 'index' is being used without being initialized.
The problem is what the error says "The variable 'index' is being used without being initialized."
It can't be clearer than that...
Lines 14 and 17
You've got to be kidding:

The variable 'index' is being used without being initialized.

EDIT: or what Bazzy said
Last edited on
Yeah, sorry. It's been a long day. I don't know what's wrong with me.
Topic archived. No new replies allowed.