Advertisement

gets() Problems

Started by July 07, 2002 10:44 AM
0 comments, last by ShadowGlance 22 years, 5 months ago
My problem is that when gets() is supposed to execute and get the title of the website then it just skips over it and continues to execute the next lines of code. Just for some background informaton here is the function that gets() is in :
  
void personnel_site(void)
{
	//Array Declarations

	char title[50];
	char url[30];
	char first_name[20];
	char last_name[30];
	
	//Variable Declarations

	int month_created;
	int day_created;
	int year_created;
	int month_seen;
	int day_seen;
	int year_seen;

	cout << "What is the Author's first and last name name?" << endl;
	cin >> first_name >> last_name;

	cout << "What is the title of the web page?" << endl;
	gets(title);

	cout << "What is the URL of the webpage?" << endl;
	cin >> url;

	cout << "On what date was the page created? (month day year)" << endl;
	cin >> month_created >> day_created >> year_created;

	cout << "On what date did you view the webpage? (month day year)" << endl;
	cin >> month_seen >> day_seen >> year_seen;

	cout << first_name << "," << last_name << "." << day_created << month_created << "." << year_created << "." << day_seen << month_seen << "." << year_seen << "." << endl;
	cout << "          " << url;

}
  
"I bow to no one and give service only to cause" [edited by - ShadowGlance on July 7, 2002 11:45:07 AM]
"I bow to no one and give service only to cause"
I know a number of things that could cause gets/fgets to do that, but you probably shouldn''t be mixing C I/O with C++ I/O anyway. I''m pretty sure that istream::getline does what you want to do with gets anyway (with cin being derived from an istream).

This topic is closed to new replies.

Advertisement