Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] How do you?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Tue Aug 14, 2007 9:44 pm    Post subject: [C++] How do you? Reply with quote

In Visual C++ all I've done is use the
Code:
system("pause")

and
Code:
cin.get()

to stop the program from closing itself immediately, but I was wondering if there was a way to restart the program instead of closing it? Or a code that stops the program from closing until you click the X on the top right hand corner.

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Aug 14, 2007 9:47 pm    Post subject: Reply with quote

while loop
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Aug 14, 2007 10:22 pm    Post subject: Reply with quote

_getch()

but if you ran the program from the command line you wouldn't have this issue in the first place
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Wed Aug 15, 2007 12:47 pm    Post subject: Reply with quote

you can also use the goto syntax and the systen("cls") and system("pause>nul")

code template:

Code:

#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
begin:
cout << "Hello World!\n";
system("pause>nul"); //wait till keyboard pressed
system("cls"); //erase all from command line
goto begin;
return 0;
}


never ending*

use with switch function for better resault.

_________________
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Aug 15, 2007 3:46 pm    Post subject: Reply with quote

ugh, goto is nasty
behold my probably less than perfect example.

Code:
#include <iostream>
using namespace std;

char option;

int main ()
{

   while (option != 'n')
   {
      cout << "1. Diques\n";
      cout << "2. Coques\n\n";
      cin >> option; 

      switch(option)
      {
      case '1':
         cout << "Diques\n";
         cout << "Want to do something else? (y / n) ";
         cin >> option;
         break;

      case '2':      
         cout << "Coques\n";
         cout << "Want to do something else? (y / n) ";
         cin >> option;
         break;

      case 'y':      
         cout << "1. Diques\n";
         cout << "2. Coques\n\n";
         cin >> option; 
         break;
      }
   }
   return 0;
}
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Wed Aug 15, 2007 9:40 pm    Post subject: Reply with quote

You should use a do-while loop instead of a while loop because you do not yet have any input at the beginning of the program.
_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites