I just started with the class vector, but it didn't go so well. :(

I tried this:

void Initialize()
{
	int amount_of_char = 62;

	vector<char> char_table;
	for (int i = 97; i < 122+1; i++)	// 97 -> 'a', 122 -> 'z'
		char_table[i] = char(i);
	for (int i = 65; i < 90+1; i++)	// 65 -> 'A', 90 -> 'Z'
		char_table[i] = char(i);
	for (int i = 48; i < 57+1; i++)	// 48 -> '0', 57 -> '9'
		char_table[i] = char(i);

	for (int i = 0; i < int(char_table.size()); i++)
		std::cout << char_table[i];
}

It compiles without errors, but I get an Assertion error when I run the program: "Vector subscript out of range".

What is that?
I tried other ctors, like:

vector<char> char_table(100);

But it does not work.

Please Help

You need to pre-initialize your array as you have gaps that aren't set with valid values! {0...47}, {58...64}, {91...96}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.