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 to make it freeze on cmd window?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
deleted19776
I post too much
Reputation: 11

Joined: 29 Apr 2007
Posts: 3838

PostPosted: Tue Sep 23, 2008 8:15 pm    Post subject: [C++] How to make it freeze on cmd window? Reply with quote

I've apparently did try messing with variables, it compiled successfully, but i need it to "pause" on the cmd window.
Source:
Code:
// operating with variables

#include <iostream>
using namespace std;

int main ()
{
  // declaring variables:
  int a, b;
  int result;

  // process:
  a = 5;
  b = 2;
  a = a + 1;
  result = a - b;

  // print out the result:
  cout << result;

  // terminate the program:
  return 0;
}

I was messing with the variables, i'm just starting, but how do you make it like freeze on saying "4"?
I double clicked and compiled the .exe, but it just shows me a cmd window for quite a little while.
My dad wants me to learn C++ by next year, so i really need you guys's help.
Exe attached, even if you don't need it, lol.
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 Sep 23, 2008 8:16 pm    Post subject: Reply with quote

cin.sync()
cin.ignore()
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Tue Sep 23, 2008 8:22 pm    Post subject: Reply with quote

slovach wrote:
cin.sync()
cin.ignore()


Agreed. Use this. No doubt, other people will come in this thread telling you to use system("PAUSE") and such, but the code slovach method uses the least amount of resources (and doesnt add extra lines saying "Press any key to continue...)

_________________
Back to top
View user's profile Send private message
deleted19776
I post too much
Reputation: 11

Joined: 29 Apr 2007
Posts: 3838

PostPosted: Tue Sep 23, 2008 8:23 pm    Post subject: Reply with quote

slovach wrote:
cin.sync()
cin.ignore()

Thank you!!!
And i won't make the common mistake of not putting ";" at the end of lines Rolling Eyes.
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Wed Sep 24, 2008 3:36 pm    Post subject: Reply with quote

I use getchar(), one line less trying I don't care if it takes more resource or what ever.
_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
Fredd
Expert Cheater
Reputation: 0

Joined: 18 Mar 2008
Posts: 240
Location: Somewhere past the rainbow, past the gold.....

PostPosted: Wed Sep 24, 2008 8:31 pm    Post subject: Reply with quote

I asked this same question, and got something complicated no one would explain. Explain this so I know what the hell it's doing to keep it open?

Also, waxxup, you didn't need to declare "results"- in the cout you can just do "cout a+b;" or so. (wrong I know.)
[/code]

_________________


Last edited by Fredd on Wed Sep 24, 2008 8:42 pm; edited 1 time in total
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 Sep 24, 2008 8:37 pm    Post subject: Reply with quote

Fredd wrote:
I asked this same question, and got something complicated no one would explain. Explain this so I know what the hell it's doing to keep it open?


sync basically discards unread characters from the input buffer.
ignore ignores a part of input.
Back to top
View user's profile Send private message
Fredd
Expert Cheater
Reputation: 0

Joined: 18 Mar 2008
Posts: 240
Location: Somewhere past the rainbow, past the gold.....

PostPosted: Wed Sep 24, 2008 8:48 pm    Post subject: Reply with quote

I still don't get how that makes it stay open...
_________________
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 Sep 24, 2008 9:11 pm    Post subject: Reply with quote

Fredd wrote:
I still don't get how that makes it stay open...


because it needs to be executed before the program can continue. look at my other post, and there is your answer.
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Wed Sep 24, 2008 10:18 pm    Post subject: Reply with quote

HornyAZNBoy wrote:
I use getchar(), one line less trying I don't care if it takes more resource or what ever.


Doesnt that require an extra #include though?

_________________
Back to top
View user's profile Send private message
Fredd
Expert Cheater
Reputation: 0

Joined: 18 Mar 2008
Posts: 240
Location: Somewhere past the rainbow, past the gold.....

PostPosted: Sat Sep 27, 2008 6:16 pm    Post subject: Reply with quote

slovach wrote:
Fredd wrote:
I still don't get how that makes it stay open...


because it needs to be executed before the program can continue. look at my other post, and there is your answer.


That other post, in idiot terms please?

_________________
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Sun Sep 28, 2008 5:57 am    Post subject: Reply with quote

Code:
SYSTEM("PAUSE")

_________________
Gone
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Sep 28, 2008 6:07 am    Post subject: Reply with quote

I use Sleep() and a infinite loop or a condition loop.
Back to top
View user's profile Send private message
scuba111223
Master Cheater
Reputation: 0

Joined: 10 Sep 2008
Posts: 275

PostPosted: Sun Sep 28, 2008 7:32 am    Post subject: Reply with quote

im pretty new to c++ but can you use cin.get(); ?
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sun Sep 28, 2008 9:31 am    Post subject: Reply with quote

GMZorita wrote:
Code:
SYSTEM("PAUSE")


Are you mad!?

Code:
lol:
 goto lol;


We ALL know that this is a lot more efficient and is used in professional programs.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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