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 


Program exiting automatically
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
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Oct 24, 2008 8:05 pm    Post subject: Program exiting automatically Reply with quote

What command would I use to make a program not automatically exit?

I think I have a clue something like
Code:
exit == true


but I tried that, but it didn't work.

_________________
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Oct 24, 2008 8:12 pm    Post subject: Reply with quote

run it from the command line.
Back to top
View user's profile Send private message
Frostbyt3
Master Cheater
Reputation: 0

Joined: 07 Jan 2008
Posts: 323
Location: Australia

PostPosted: Fri Oct 24, 2008 8:18 pm    Post subject: Reply with quote

Code:
while (exit == false)
{
//Do something
if input = "exit"
exit = true;
}

Pseudo code for a loop.

A better way is to get input using a switch.
Back to top
View user's profile Send private message MSN Messenger
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Oct 24, 2008 8:28 pm    Post subject: Reply with quote

Okay, I don't really know what I'm doing wrong, but can you please tell me?

Code:
// my second program in C++

#include <iostream>

using namespace std;

int main ()
{
  cout << "Hello World! ";
  cout << "I'm a C++ program";
  return 0;
}

while {exit == false}
{
   cout << "You can now exit. ";
   if input = "exit"
      exit = true
}


http://pastebin.com/d2afed972

These are the 4 errors I'm getting:

d:\documents and settings\owner\my documents\visual studio 2008\projects\hello world!\hello world!\hello world.cpp(14) : error C2059: syntax error : 'while'

d:\documents and settings\owner\my documents\visual studio 2008\projects\hello world!\hello world!\hello world.cpp(14) : error C2143: syntax error : missing ';' before '{'

d:\documents and settings\owner\my documents\visual studio 2008\projects\hello world!\hello world!\hello world.cpp(14) : error C2447: '{' : missing function header (old-style formal list?)

d:\documents and settings\owner\my documents\visual studio 2008\projects\hello world!\hello world!\hello world.cpp(15) : error C2447: '{' : missing function header (old-style formal list?)

_________________


Last edited by xV on Fri Oct 24, 2008 8:30 pm; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
dEEznutz
Grandmaster Cheater
Reputation: 0

Joined: 29 Nov 2007
Posts: 514

PostPosted: Fri Oct 24, 2008 8:29 pm    Post subject: Reply with quote

cin.get()
?

_________________
Learning C++
Back to top
View user's profile Send private message
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Oct 24, 2008 8:31 pm    Post subject: Reply with quote

dEEznutz wrote:
cin.get()
?


Sorry, I just started learning. Can you tell me what that does and how I'll be able to use it? I'm just making a very simple program that just says a line of text. If it helps, my project is Win32, someone told me I should use that.

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

Joined: 07 Jan 2008
Posts: 323
Location: Australia

PostPosted: Fri Oct 24, 2008 8:34 pm    Post subject: Reply with quote

Your error there is that the while is never reached.

Place it in the main method, and then it'll actually be reached.

As the other guy said

Code:
cin.get();
cin.sync();


will stop the program, but you can't do anything after that. The switch method is a good way to do things.
Back to top
View user's profile Send private message MSN Messenger
clanner
Master Cheater
Reputation: 0

Joined: 26 Jul 2006
Posts: 290

PostPosted: Fri Oct 24, 2008 8:35 pm    Post subject: Reply with quote

Well, one of the really cheap ways is to add
Code:
system ("pause");

at the end of your code.
Back to top
View user's profile Send private message AIM Address
Frostbyt3
Master Cheater
Reputation: 0

Joined: 07 Jan 2008
Posts: 323
Location: Australia

PostPosted: Fri Oct 24, 2008 8:37 pm    Post subject: Reply with quote

clanner wrote:
Well, one of the really cheap ways is to add
Code:
system ("pause");

at the end of your code.


Thats also a pretty bad way...
Back to top
View user's profile Send private message MSN Messenger
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Oct 24, 2008 8:39 pm    Post subject: Reply with quote

Clanner, I tried to put your code into this simple code and I get 2 errors.

http://pastebin.com/d6d09cc99

Errors:

Quote:
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup


Quote:
D:\Documents and Settings\owner\My Documents\Visual Studio 2008\Projects\My First Project!\Debug\My First Project!.exe : fatal error LNK1120: 1 unresolved externals

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

Joined: 29 Nov 2007
Posts: 514

PostPosted: Fri Oct 24, 2008 8:40 pm    Post subject: Reply with quote

Frostbyt3 wrote:
clanner wrote:
Well, one of the really cheap ways is to add
Code:
system ("pause");

at the end of your code.


Thats also a pretty bad way...

Seriously, do not use that.
Try putting it before return 0;

_________________
Learning C++
Back to top
View user's profile Send private message
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Oct 24, 2008 8:47 pm    Post subject: Reply with quote

I went back to what Frostbyt3 said and used this code:

Code:
// my second program in C++

#include <iostream>

using namespace std;

int main ()
{
   while (exit == false)
   {
  cout << "Hello World! ";
  cout << "I'm a C++ program";
  return 0;
if input = "exit"
exit = true;
   }
}


And returned with only one error, not a really big error I think.

Quote:
D:\documents and settings\owner\my documents\visual studio 2008\projects\my first project!\my first project!\hello.cpp(14) : error C2061: syntax error : identifier 'input'


Do you know what's wrong?

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

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri Oct 24, 2008 8:47 pm    Post subject: Reply with quote

you stuffed up lots of this

Code:
while (exit == false)
{
   cout << "You can now exit. ";
   if input = "exit"
      exit = true;
}


wrong brackets and no ; its fixed

also, go and look at some basic C++ tutorials because they are far easier than asking us everything

_________________
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Oct 24, 2008 8:49 pm    Post subject: Reply with quote

cin.sync
cin.ignore / get.

Code:
#include <iostream>

int main (){
   std::cout << "Hello World!";
   std::cout << "I'm a C++ program";
   std::cin.sync();
   std::cin.ignore();
   return 0;
}


Last edited by hcavolsdsadgadsg on Fri Oct 24, 2008 8:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Oct 24, 2008 9:15 pm    Post subject: Reply with quote

slovach wrote:
cin.sync
cin.ignore / get.

Code:
#include <iostream>

int main (){
   std::cout << "Hello World!";
   std::cout << "I'm a C++ program";
   std::cin.sync();
   std::cin.ignore();
   return 0;
}


:O What's all that std stuff?

Could I get rid of all that std:: if I used:
Code:
using namespace std;

_________________
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