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++ Help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
FirePhoenix
Grandmaster Cheater
Reputation: 0

Joined: 22 Jan 2008
Posts: 575

PostPosted: Tue Mar 03, 2009 8:25 pm    Post subject: C++ Help Reply with quote

Ok I just started learning C++ about 3 days ago so I decided to create a simple program. So I thought I might just make a program that gives you math questions (dumb I know) anyways it works fine so my problem is I want the last line to be able to be read. So for example cout << " You have gotten 4/5 correct good job"; so after return 0; when its compiled and run it closes after that cout line right away so I want it to be able to stop and have users the ability to close the program or restart it so what function would I use?
_________________
Currently learning C++. You can't stop me babe!!!
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Tue Mar 03, 2009 8:36 pm    Post subject: Reply with quote

Use the sleep(int) function.
Back to top
View user's profile Send private message
FirePhoenix
Grandmaster Cheater
Reputation: 0

Joined: 22 Jan 2008
Posts: 575

PostPosted: Tue Mar 03, 2009 8:45 pm    Post subject: Reply with quote

nwongfeiying wrote:
Use the sleep(int) function.


Um ok how would I fit that into my source? sleep Piss;?

_________________
Currently learning C++. You can't stop me babe!!!
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Tue Mar 03, 2009 8:57 pm    Post subject: Reply with quote

nwong was saying use
Code:
Sleep(1000);

Which would make it Sleep or pause at that line for 1 second (you can change it)


simplest way is to add
Code:
system("PAUSE");
at the end of your code

however, it isnt the most memory efficient.




the best way is to add

Code:
std::cin.sync();
std::cin.ignore();


remove the std:: 's if you added
Code:
using namespace std;
to your code
_________________
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Tue Mar 03, 2009 9:02 pm    Post subject: Reply with quote

Quote:
Use the sleep(int) function.

That was a horrible suggestion. He wants to be able to start the proggram again from the beginning without reopening, not pause execution (but you suggestion would still be shit).
It's time for you to learn about loops. There's for, while, and do while loops. While will be the easiest to use although do while would work better.
Basically, everything in the while loop will execute then repeat as long as a conditional (like if statement) is true.
Code:

int doProgram = 1;
while(doProgram == 1){
all your code;
cout >> "again? 1 - yes, 0 - no";
cin << doProgram;}
return 0;

When it gets to the loop, it'll check if the statement is true or false. if it's false, it'll skip over it. if true, it'll start the loop. When it gets to the end of the loop, execution will go right back to the start of the loop and check the conditional again.

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

Joined: 22 Jan 2008
Posts: 575

PostPosted: Tue Mar 03, 2009 9:24 pm    Post subject: Reply with quote

HalfPrime wrote:
Quote:
Use the sleep(int) function.

That was a horrible suggestion. He wants to be able to start the proggram again from the beginning without reopening, not pause execution (but you suggestion would still be shit).
It's time for you to learn about loops. There's for, while, and do while loops. While will be the easiest to use although do while would work better.
Basically, everything in the while loop will execute then repeat as long as a conditional (like if statement) is true.
Code:

int doProgram = 1;
while(doProgram == 1){
all your code;
cout >> "again? 1 - yes, 0 - no";
cin << doProgram;}
return 0;

When it gets to the loop, it'll check if the statement is true or false. if it's false, it'll skip over it. if true, it'll start the loop. When it gets to the end of the loop, execution will go right back to the start of the loop and check the conditional again.


Ok you guys here's the source, at the end of the program I would like to add a line that gives the user a choice to restart or close.

Code:
//attempting to create a program

#include <iostream>
using namespace std;

int main ()
{

int Iss;
cout << "Math Pratice Elite: Made by FirePhoenix\n";
cout << "\nSimply answer a few math questions, to see how good you are at Math!\n";
cout << "\n1. What is 1+1?: ";
cin >> Iss;
if (Iss == 2)
cout << "\nYou are correct!\n";
else
cout << "\nYour wrong.\n";
cout << "\n2. What is 4+4?: ";
cin >> Iss;
if (Iss == 8)
cout << "\nYou are correct!\n";
else
cout << "\nYour wrong!\n";
cout << "\n3. What is 6+6?: ";
cin >> Iss;
if (Iss == 12)
cout << "\nYou are correct!\n";
else
cout << "\nYou are wrong!\n";
cout << "\n4. What is 3+2?: ";
cin >> Iss;
if (Iss = 5)
cout << "\nYou are correct!\n";
else
cout << "\nYou are wrong!\n";
cout << "\n5. What is 4+5?: ";
cin >> Iss;
if (Iss == 9)
cout << "\nYou are correct!";
else
cout << "\n You are wrong!";

return 0;
}   


As you can see I'm only using the if else condition which seems to work fine But I get what your saying HalfPrime.

_________________
Currently learning C++. You can't stop me babe!!!


Last edited by FirePhoenix on Tue Mar 03, 2009 10:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Tue Mar 03, 2009 9:53 pm    Post subject: Reply with quote

if/if-else statements aren't loops, they're just conditionals. A loop is basically a conditional that repeats as long as it's true.

Code:

...
int Iss, doProgram;
doProgram = 1;
cout << "Math Pratice Elite: Made by FirePhoenix\n";
cout << "\nSimply answer a few math questions, to see how good you are at Math!\n";
while(doProgram == 1){
cout << "\n1. What is 1+1?: ";
...
if (Iss == 9)
cout << "\nYou are correct!";
else
cout << "\n You are wrong!";
cout >> "again? 1 - yes, 0 - no";
cin << doProgram;}
cout << "bb";
return 0;
}


Here's a simple example of a loop that'll print the numbers from 1-10
Code:

int c=1;
while(c<=10){
cout >> c;
c++;}

_________________
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Tue Mar 03, 2009 10:09 pm    Post subject: Reply with quote

Halfprime, you evaluate me and so I will evaluate you.

I think your suggestion is shit because you only explain the basics of the loop and neglected to teach him how to create a function and call it.

Rolling Eyes
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Tue Mar 03, 2009 10:17 pm    Post subject: Reply with quote

nwongfeiying wrote:
[you] neglected to teach him how to create a function and call it.


Why would he need to be calling functions for something that simple?

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

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Mar 03, 2009 10:19 pm    Post subject: Reply with quote

Code:

BOOL NopSleep(int NumofSomekind..)
{
__asm
{
xor eax,eax//zero out eax so eax = 0...
loop:
nop
nop
nop
nop
nop
//enough nops for a whole second (not included)...
inc eax//increment eax so eax = eax + 1(i mean that it increments the number sequentially..)
cmp eax, NumofSomeKind//compare the incremented value to the number inputed..
jl loop//repeat the look if eax less then
}
MessageBoxW(0,L"Hello World",L"Yall can byte me..",0);
return
}
Back to top
View user's profile Send private message MSN Messenger
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Tue Mar 03, 2009 10:46 pm    Post subject: Reply with quote

manc wrote:
nwongfeiying wrote:
[you] neglected to teach him how to create a function and call it.


Why would he need to be calling functions for something that simple?


He'll need to learn it sooner or later.
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Tue Mar 03, 2009 10:51 pm    Post subject: Reply with quote

nwongfeiying wrote:
Halfprime, you evaluate me and so I will evaluate you.

I think your suggestion is shit because you only explain the basics of the loop and neglected to teach him how to create a function and call it.

Rolling Eyes

Good thing I in no way care what you think, then.
As for functions, he will learn them when he gets to them. No point in causing confusion by skipping steps. Btw, yours didn't show him how to create a function, either so I guess by your standards, your post is double shit.

_________________
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Tue Mar 03, 2009 10:53 pm    Post subject: Reply with quote

HalfPrime wrote:
nwongfeiying wrote:
Halfprime, you evaluate me and so I will evaluate you.

I think your suggestion is shit because you only explain the basics of the loop and neglected to teach him how to create a function and call it.

Rolling Eyes

Good thing I in no way care what you think, then.
As for functions, he will learn them when he gets to them. No point in causing confusion by skipping steps. Btw, yours didn't show him how to create a function, either so I guess by your standards, your post is double shit.


Well, you didn't teach him in the quoted post above. So, your post is triple shit Twisted Evil
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Tue Mar 03, 2009 11:11 pm    Post subject: Reply with quote

nwongfeiying wrote:
HalfPrime wrote:
nwongfeiying wrote:
Halfprime, you evaluate me and so I will evaluate you.

I think your suggestion is shit because you only explain the basics of the loop and neglected to teach him how to create a function and call it.

Rolling Eyes

Good thing I in no way care what you think, then.
As for functions, he will learn them when he gets to them. No point in causing confusion by skipping steps. Btw, yours didn't show him how to create a function, either so I guess by your standards, your post is double shit.


Well, you didn't teach him in the quoted post above. So, your post is triple shit Twisted Evil

He's obviously following a tutorial already and will get there at his own pace. If he has any problems with it then, he can come and ask for more help. I just hope there's someone other than you here when he does so he can get some real help.

_________________
Back to top
View user's profile Send private message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Wed Mar 04, 2009 5:18 am    Post subject: Reply with quote

nwongfeiying wrote:
HalfPrime wrote:
nwongfeiying wrote:
Halfprime, you evaluate me and so I will evaluate you.

I think your suggestion is shit because you only explain the basics of the loop and neglected to teach him how to create a function and call it.

Rolling Eyes

Good thing I in no way care what you think, then.
As for functions, he will learn them when he gets to them. No point in causing confusion by skipping steps. Btw, yours didn't show him how to create a function, either so I guess by your standards, your post is double shit.


Well, you didn't teach him in the quoted post above. So, your post is triple shit Twisted Evil

Your posts are always shit. Laughing Rolling Eyes

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
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