Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-03-2005, 08:29 PM   #1 (permalink)
enternal
Registered User
 
Join Date: Feb 2005
Posts: 2
enternal is on a distinguished road
Problem with loop

The program runs fine the first time through, but when asked to do another, it gets to in_name(), prints "Enter your full name:" and then it errors with "Aborted" and exits. I've tried setting full="" and cin.clear() but still nothing.
Here are two the relevant functions:

Code:
int main() 
{
char cont = 'Y';

while(cont == 'Y')
{

	in_name();
	parse();
	out_name();
	cout<<"Another? ([Y]es or [No)";
	cin >> cont;
	cont = toupper(cont);
}

return 0;
}
Code:
void in_name()
{
	cout << "Enter your full name: ";
	getline(cin, full);
}
enternal is offline   Reply With Quote
Old 02-03-2005, 08:50 PM   #2 (permalink)
enternal
Registered User
 
Join Date: Feb 2005
Posts: 2
enternal is on a distinguished road
Nevermind, got it

Code:
int main() 
{
char cont = 'Y';

while(cont == 'Y')
{

	in_name();
	parse();
	out_name();
	cout<<"Another? ([Y]es or [No)";
	cin >> cont;
	cin.ignore(INT_MAX, '\n');
        cont = toupper(cont);
}

return 0;
}
enternal is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Assignment (Urgent help req.) Boltress Standard C, C++ 0 01-12-2005 08:59 AM
problem implementing RC4/ciphersaber 2 Spook Standard C, C++ 3 01-10-2005 04:25 AM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 05:44 PM
Breaking out of external loop agh Standard C, C++ 7 04-30-2003 09:03 PM
the endless loop loop loop loop loop loop ... abc123 All Other Coding Languages 2 08-14-2002 04:43 PM


All times are GMT -8. The time now is 08:14 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting