cout problems

I have some code:
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
int main()
{
	bool success = true;	
	nodePtr head = NULL;
	int skipNum;
	char file[MAXFILENAME];	

	cout << "Enter the skip number: ";
	cin >> skipNum;

	cout << "\nEnter the file name: ";
	cin.ignore( 256, '\n' );
	cin.getline( file, MAXFILENAME );
	

	fillList (head, file, success );

	cout << "\nSize=" << length( head ) <<": (";
	printCircList( head, success );
	cout << ")";	

	return 0;

	
}


which is pretty simple. However, whenever the program runs, it is printing
Enter the skip number: ( user input here )

Enter the file name: ( more input )

Size=(listSize): ( ... ) 


I cannot, for the life of me, figure out why those empty lines are there. I'm sure it's a simple mistake because it's 2:15 in the morning and I'm programming on Black Blood Of The Earth. If anybody sees what would cause that damned empty line, please tell me.

Last edited on
The first line break comes when the user presses enter. The second line break comes when you on line 11 outputs the line break char \n.
So how do I get rid of the line breaks for the user pressing enter?
cin.ignore() won't do it, will it?
You can't.
Nevermind, I'm definitely tired. Just getting rid of the newline characters. Thanks for the input!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main()
{
	bool success = true;	
	nodePtr head = NULL;
	int skipNum;
	char file[MAXFILENAME];	

	cout << "Enter the skip number: ";
	cin >> skipNum;
//	cin.ignore( 256, '\n' );
	cout << "Enter the file name: ";
	cin.getline( file, MAXFILENAME );

	fillList (head, file, success );
	cout << "Size=" << length( head ) <<": (";
	printCircList( head, success );
	cout << ")";	
	return 0;
}
Topic archived. No new replies allowed.