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 


Two tiny c++ questions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Engineer
Expert Cheater
Reputation: 1

Joined: 25 Nov 2007
Posts: 170

PostPosted: Fri Jan 04, 2008 11:58 am    Post subject: Two tiny c++ questions Reply with quote

Is there a command to clean cmd\dos screen?

How do i make a looping function that repeats every 1 second?

thanks...
Back to top
View user's profile Send private message
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Fri Jan 04, 2008 12:18 pm    Post subject: Reply with quote

hers a function that Ive used before:

Code:
void ClearScreen()
{
  HANDLE hSTD = GetStdHandle(STD_OUTPUT_HANDLE);
  COORD coordinates = {0,0};
  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
  GetConsoleScreenBufferInfo(hSTD, &buffer_info);
  FillConsoleOutputCharacter(hSTD, ' ', buffer_info.dwSize.X * buffer_info.dwSize.Y, coordinates, NULL);
  SetConsoleCursorPosition(hSTD, coordinates);
}


I've had it sitting in a folder for so long I cant remember if I wrote it or someone else did...

as for the loop, you could either use a timer or you could use a timer and just sleep but if you go for the latter, you might wanna do it in a different thread (I dunno, depends on what you want).

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Jan 04, 2008 12:30 pm    Post subject: Reply with quote

Can't you use System("cls");? I don't know much C++, I remember when I used System it was like batch... System("echo ..."); and System("Pause"); so I guess cls will work too.
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Fri Jan 04, 2008 12:33 pm    Post subject: Re: Two tiny c++ questions Reply with quote

ZzOoZz wrote:
How do i make a looping function that repeats every 1 second?


What do you want it to do?

If it does nothing

Code:

for ( ; ; ) //never ending
{
      Sleep(1000); //pause for a second--I think that's how you do it
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended


Last edited by samuri25404 on Sat Jan 05, 2008 7:24 am; edited 1 time in total
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jan 04, 2008 6:36 pm    Post subject: Reply with quote

Use a while statement instead of an endless for loop. Have the condition a toggled boolean or something of the sort so it has an escape method and doesn't just get stuck in memory. (Just a suggestion.)

@Sam: Yea you can use System("cls") most don't use the System() command though due to overhead and sloppy methods. If you google pros and cons of System() you should find some interesting reads about how it creates a lot of overhead for simple tasks such as cls.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Engineer
Expert Cheater
Reputation: 1

Joined: 25 Nov 2007
Posts: 170

PostPosted: Sat Jan 05, 2008 6:34 am    Post subject: Re: Two tiny c++ questions Reply with quote

[quote="samuri25404"][quote="ZzOoZz"]How do i make a looping function that repeats every 1 second?
Quote:


What do you want it to do?

If it does nothing

Code:

for ( ; ; ) //never ending
{
      Sleep(1000); //pause for a second--I think that's how you do it
}




its not working. my compliler says sleep() isnt a function
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sat Jan 05, 2008 6:41 am    Post subject: Reply with quote

I think you need to include "dos" or "dos.h"... and try sleep, maybe its case sensetive.
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: Sat Jan 05, 2008 7:02 am    Post subject: Reply with quote

Symbol wrote:
I think you need to include "dos" or "dos.h"... and try sleep, maybe its case sensetive.


unistd.h
Sleep(10);
Back to top
View user's profile Send private message MSN Messenger
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sat Jan 05, 2008 7:42 am    Post subject: Reply with quote

Quote:
its not working. my compliler says sleep() isnt a function

#include Windows.h
http://msdn2.microsoft.com/en-us/library/ms686298.aspx

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
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