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 


.exe files closing immediately.
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
SirSteez
Newbie cheater
Reputation: 0

Joined: 10 Nov 2007
Posts: 19

PostPosted: Thu Jan 31, 2008 5:10 pm    Post subject: Reply with quote

Omg.. lol.
thanks HolyBlah for reminding me of an old method in particular and the others who helped me in solving this issue Razz.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Thu Jan 31, 2008 6:19 pm    Post subject: Reply with quote

iCucco wrote:
SirSteez wrote:
haha alright thanks guys i'll try those.

where would i insert those in
Code:

#include <iostream>

int main();
int main()
{
    std::cout << "Hello World!\n";
    return 0;
}

and is having both the "int main()"'s necessary?
I tried putting in the Sleep(INFINITE); right after return 0; and that didn't work.
I also tried guernica's method after the } and also tried replacing it with the current return 0;, neither worked.
In cmd prompt I went to the .exe's destination folder and tried running the program there but it said "'hello world.exe' wasn't recognized as an internal or external command or as an operable program or batch file.

although i found out keeping cmd prompt open isn't really necessary, for my compiler shows what the program does below the source.. >_<


It doesn't work because
Code:
return 0;
is the exit call for the main thread. If you put code after that call, it will not be executed. Put it this way:
Code:
 Sleep(INFINITE); return 0;


Although it's not necessary to put in "return 0;" if you are planning to use Sleep(INFINITE) it's better to be sure that your program is terminated if something unusual happens.

As for the code:
Code:

#include <iostream>
#include <windows.h>
#define WIN32_LEAN_AND_MEAN

using namespace std;
int main()
{
    cout << "Hello World!"<<endl;
    Sleep(INFINITE);
    return 0;
}


@Wiccaan: You're absolutely right, system("pause"); is awful way of stopping the application, but it is a method to do that anyways.


Dear god don't use something like Sleep( infinite ); just to have a program pause... there is absolutely no reason for you to do that.. You are already using iostream and the std namespace, just use the cin features to pause the program..

Code:

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


Or as x0r pointed out, you can also use _getch() which is defined in conio.h.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
SirSteez
Newbie cheater
Reputation: 0

Joined: 10 Nov 2007
Posts: 19

PostPosted: Sun Feb 03, 2008 1:18 pm    Post subject: Reply with quote

thanks for the help everyone =)
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
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