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 


[Need Help] Calling back to "main()" in C++
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Nov 13, 2007 8:44 pm    Post subject: Reply with quote

TheSorc3r3r wrote:
Umm.. if you want to call main:

main();

Lol

btw, if you want to program GUIs, look at www.functionx.com/win32


That will eventually result in a stack overflow, so it is a horrible thing to do.
Back to top
View user's profile Send private message
seeplusplus
Grandmaster Cheater
Reputation: 0

Joined: 28 Oct 2007
Posts: 562
Location: cracking accounts

PostPosted: Tue Nov 13, 2007 9:08 pm    Post subject: Reply with quote

way to copy meh... Rolling Eyes

Jk

_________________
I am xwallflowerx...this will probably be deleted soon...
Back to top
View user's profile Send private message
mOnSoOn
Expert Cheater
Reputation: 0

Joined: 05 Jul 2007
Posts: 203

PostPosted: Tue Nov 13, 2007 9:57 pm    Post subject: Reply with quote

Ofcourse looping.
I think you should use the WHILE loop then you will do like this:
Code:
int BackStay = 1;
While(BackStay==1) {
// -----code below-----
...
...
...
...

//When you want to back "Main"
//just increase or decrease BackStay.
// (BackMain++) then the While loop will break. or even use the break operator.
}
Back to top
View user's profile Send private message MSN Messenger
M3KillU
Grandmaster Cheater
Reputation: 0

Joined: 06 Apr 2007
Posts: 793
Location: California, USA

PostPosted: Wed Nov 14, 2007 9:18 am    Post subject: Reply with quote

TheSorc3r3r wrote:
Umm.. if you want to call main:

main();

Lol

btw, if you want to program GUIs, look at www.functionx.com/win32


Thanks for the website.
Also... you can't call to "int main()" using
main();

It doesn't work. You can call void doing that. That is why I modified my script.

_________________
This is where my siggy goes!
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Wed Nov 14, 2007 9:23 am    Post subject: Reply with quote

M3KillU wrote:
Thanks for the website.
Also... you can't call to "int main()" using
main();

It doesn't work. You can call void doing that. That is why I modified my script.


Flyte wrote:
That will eventually result in a stack overflow, so it is a horrible thing to do.
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Wed Nov 14, 2007 2:15 pm    Post subject: Reply with quote

Flyte wrote:
TheSorc3r3r wrote:
Umm.. if you want to call main:

main();

Lol

btw, if you want to program GUIs, look at www.functionx.com/win32


That will eventually result in a stack overflow, so it is a horrible thing to do.


keyword being eventually =D

_________________


Don't laugh, I'm still learning photoshop!
Back to top
View user's profile Send private message
M3KillU
Grandmaster Cheater
Reputation: 0

Joined: 06 Apr 2007
Posts: 793
Location: California, USA

PostPosted: Wed Nov 14, 2007 5:44 pm    Post subject: Reply with quote

I was saying it doesn't work... period...
My compiler won't let me do it.
How do you use an if comparison to see if someone typed a text you wanted?

like...

Code:

void question()
{
   int answer;
   cout << "\n\nWhat language do most Americans speak?\n";
   cin >> answer;
   if (answer /*English*/) {
        cout << "Whatever....\n\n";
   }
   else {
        cout << "Loser, try again."
        question();
   }

int main()
{
   question();
   return 0;
   system("PAUSE");
}


________________________________

Does anyone know how to make it not close out after you are done? Like how it will prompt you to "press any key to continue..."

_________________
This is where my siggy goes!
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Wed Nov 14, 2007 5:56 pm    Post subject: Reply with quote

M3KillU wrote:
I was saying it doesn't work... period...
My compiler won't let me do it.
How do you use an if comparison to see if someone typed a text you wanted?


strcmp()/stricmp() (_tcsicmp() if you use <tchar.h>)

M3KillU wrote:
Does anyone know how to make it not close out after you are done? Like how it will prompt you to "press any key to continue..."


Code:
std::cin.sync();
std::cin.get();
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Nov 14, 2007 5:57 pm    Post subject: Reply with quote

M3KillU:

Code:

#include <iostream>
#include <string>

void question()
{
   std::string answer;
   std::cout << std::endl << std::endl;
   std::cout << "What language do most Americans speak?" << std::endl;
   std::cin >> answer;
   if (answer == "English") {
      std::cout << "Whatever...." << std::endl << std::endl;
   } else {
      std::cout << "Loser, try again.";
      question();
   }
}

int main(int argc, char* argv[])
{
   question();
   return 0;
}

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

Joined: 06 Apr 2007
Posts: 793
Location: California, USA

PostPosted: Thu Nov 15, 2007 4:50 pm    Post subject: Reply with quote

Thank you appalsap and Flyte Very Happy
This helps A LOT.
Also appal, You changed some of the things... why? I just forgot to put in
using namespace std;
And you took the long way and put endl, rather than \n.


That's all I have for C++ for now. Thank you everyone for your help.
Don't forget to click on my sig.

_________________
This is where my siggy goes!
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 Previous  1, 2
Page 2 of 2

 
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