The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C / C++


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #11 (permalink)  
Old 11-20-2007, 12:31 PM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee is just really niceLee is just really niceLee is just really niceLee is just really nice
I am sorry but i have forgotten how to loop back, i will have to look it up if someone doesn't beat me too it, to stop the window closing use system("PAUSE"); make sure it is within you main section though, e.g:
Quote:
//that stuff (iostream and whatnot) don't know off the top of my head atm.

int main(){
int a,b;
string name;
cout
<< "Hello, What's your name? \n";
getline(cin,name);
cout
<< "Please enter a value" << name << ".\n";
getline(cin,a);
cout
<< "Please enter another value.";
getline(cin,b);
if(a == b){
cout
<< "a = b";
return 0;
} else {
cout
<< "Try again";
//Now it would go back to the second cout?
}

system("PAUSE");
}
Reply With Quote
The Following User Says Thank You to Lee For This Useful Post:
MrPickle (11-20-2007)
  #12 (permalink)  
Old 11-20-2007, 12:32 PM
MrPickle's Avatar
MrPickle MrPickle is offline
Sr. Programmer
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 305
iTrader: (0)
MrPickle is on a distinguished roadMrPickle is on a distinguished roadMrPickle is on a distinguished road
Thanks Lee.

__________________
PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #13 (permalink)  
Old 11-30-2007, 05:19 AM
Bench Bench is offline
Full Programmer
Join Date: Jul 2007
Location: UK
Posts: 113
iTrader: (0)
Bench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished road
Quote:
Originally Posted by MrPickle View Post
Woo hoo! Thanks!!



Please show me how, I've only started learning today.

On a different subject, is there a way to prevent the command prompt from closing? EG make it close when you press Enter?
Windows automatically closes a command prompt window when a program has finished running. As far as I know, there's no way to stop windows from doing that, so you need to find some way to stop your program from finishing, until you want it to.

If you use MS Visual Studio as your IDE, then use [CTRL]+[F5] to compile/run your programs. VS will add a "pause" after your program finishes.

if you're not using MSVC, then have a look at this link
Cprogramming.com: FAQ

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


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

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



All times are GMT -7. The time now is 06:35 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50