3.1 - ARRAY arguments, char vs int.
It seems you pass a char OR an int to a substring of an array. Does it matter which one?

ex:

char charValue = 5;
	int intValue = 5;
	string awesomeArray[9] = {"truck", "car", "boat", "table", "ocean", "cat", "board", "finicky"};
	
	//Both of these work. Is either a better choice?
	cout << awesomeArray[charValue];
	cout << awesomeArray[intValue];
	
	system("PAUSE");
	return 0;

>>Does it matter which one?
No. You can use either, but integers are most common. If you use char then the compiler will have to take the time to promote it to an integer before its used as the index into the array. So you can speed up a program by a few nanoseconds by using ints instead of char.

They both work because a char is really just a small int (1-byte instead of typically 4-bytes). The difference is the way the system interprets them by default.

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.