Extra empty line appearing using cout

Hi,

I am new to c++ and have started creating a dummy program to perform a simple task of writing a few strings to the console, which are first generated using random generation.

When I execute the code, an extra line for each generated object appears in the console.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int gemNum;
cout << "This program calculates the value and type of gems\n";
cout << "Please enter the number of gems: ";
cin >> gemNum;
vector<int> gemVector(gemNum);
vector<int> gemCollection = fillGemCollection(gemNum);
vector<int> gemSort = sortGems(gemCollection);
	
vector<string> gemResult = finalGemValue(gemNum, gemSort);

for(int i = 0; i<gemResult.size();i++){
	string gemString = gemResult[i];
	cout << gemString << endl; 
}



This program calculates the value and type of gems
Please enter the number of gems: 4




10 hematite
40 carnelian
60 onyx
120 silver pearl
Press "e" and enter to end program
We would need to see at least the definitions for the functions you are calling, but have you tried stepping through with a debugger to see when those extra lines appear?
Topic archived. No new replies allowed.