#include <iostream>
using namespace std;

int main()
{	
	char A,B,C,D;
	const char capacity = 120;
	char letter[capacity];
	int pax = 0;

	int y =6;
	
	for (int i = 0; i < capacity; i++)
		{
		if ( y == 6)
			{ char letter[] = {A};
			  pax++;
			  break;
			} 
		else if ( y == 8)
			{ char letter[] = {B};
			  pax++;
			  break;
			}
		else if ( y == 12)
			{ char letter[] = {C};
			  pax++;
			  break;
			}
		else if ( y == 14)
			{ char letter[] = {D};
			  pax++;
			  break;
			}  
			
		}
		cout <<  letter[capacity]<< endl;
		cout << pax;
		return 0;
}

I don't understand why the character A isn't printed out to the screen, I would appreciate any help please as my project is due in 24hrs and this is a main part.

line 8: should be const int capacity line 9: you need to initialize all the bytes of the array with 0 so that they contain a known value char letter[capacity] = {0}; line 17: >>char letter[] = {A};
That is incorrect -- shold probably be letter[pax] = 'A'; What it should be doing is inserting the letter 'A' into the character array letter (which was declared earlier line line 9) at position pax.

line 38: should be cout << letter<< endl; because letter[capacity] is one character beyone the end of the array.

line 12: Is there some reason to hard-code the value of y to 6? Instead of getting its value from the keyboard ? With that hard-coded value it never changes so why have that loop with checks for all those values of y when there can only be one value ?

Tanks that solved some of it, but why is it cout this ╠╠╠╠╠╠╠╠└ instead of the character A!

see my comment about line 9. Initializing the array to 0 will fix that. Also make sure you have read all the other comments because I may have added some since you last read it.

Yep working perfectly now, thanks a million!! Saved me there now i can process the rest of the array program.

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.