Archived

This topic is now archived and is closed to further replies.

Thrust

Why does this require my to press enter twice?

Recommended Posts

Well after stoping on programming for a long time I decided to "relearn" C++. I wrote this code quickly but what I dont understand is why you have to press enter twice after you enter in the string. Here is the code
#include
#include
using namespace std;

int main()
{
	const int SEMHOURFEE = 100;
	const int ROOMBOARD  = 1800;
	string name          = "";
	int hours            = 0;
	int total            = 0;

	//enter input items
	cout << "Enter student name: "<< endl;
	getline(cin, name);
	cout << "Enter hours enrolled: ";
	cin >> hours;

	//calculate total owed
	total = hours * SEMHOURFEE + ROOMBOARD;

	//display output items
	cout << "Student name: " << name << endl;
	cout << "Total due: " << total << endl;


	return 0;
}
  
I just dont get it. I just hope I did the message board code thing right. [edited by - Thrust on October 22, 2003 5:52:57 PM]

Share this post


Link to post
Share on other sites
It is a bug in Visual Studio 6''s library.

See the appropriate link in my signature to fix it.



[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites