How to put an end of string mark at the end of each line in an array?

Basically I am writing a program that will ask the user to input some names and then I will sort the names.
However, right now when I input the characters, it prints out everything, including the empty spaces. How do I put an end of string mark at the end of the line, when the user hits enter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void main()
	{
	const	int			MaxNames(20);
	const	int			MaxLetters(15);
			char		Names[MaxNames + 1] [MaxLetters + 1];
			int			NumRows;
			int			Row;
			int			Col;
			int			NumCols = MaxLetters;

			cout << "How many names shall you enter?" << endl;
			NumRows = ReadInteger ();

			cout << "Enter " << NumRows << " names: " << endl;
			
			for (Row = 0; Row < NumRows; Row++)
				{
				cin.getline		(Names [Row], MaxLetters + 1, '\n');
				}

			cout << "You entered " << endl;
			for (Row = 0; Row < NumRows; Row++)
				{
				for (Col = 0; Col < NumCols; Col++)
					cout << Names[Row][Col];
					cout << endl;
						
				}
Just cout << Names[Row] on line 25.
EDIT: And erase line 24.
Last edited on
Topic archived. No new replies allowed.