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 


Quick C++ Question

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

Joined: 14 May 2007
Posts: 568

PostPosted: Sun Jan 20, 2008 3:05 pm    Post subject: Quick C++ Question Reply with quote

In a win32 console, the hello world application just runs real quick, just swiftly displaying "hello world" text.
Code:

#include <iostream>

int main()
{
   std::cout   <<   "Hello World!"   <<   std::endl;
}


How do i make that say "press any key to continue" before it ends?

Visual studio 2005


Ok i figured out to use
Code:
 system("pause");
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sun Jan 20, 2008 3:30 pm    Post subject: Reply with quote

Do i have to use sleep in c#?
_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
MegaForum
Grandmaster Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 558

PostPosted: Sun Jan 20, 2008 3:32 pm    Post subject: Reply with quote

name space std;



return 0;
Back to top
View user's profile Send private message
FullyAwesome
I post too much
Reputation: 0

Joined: 05 Apr 2007
Posts: 4438
Location: Land Down Under

PostPosted: Sun Jan 20, 2008 4:19 pm    Post subject: Reply with quote

or if you run it straight from a cmd prompt, you'll see it come up and then it will take you to the next line C:\ or w.e. you'll still see your "hello world" message above, if you know what i mean.
_________________
Back to top
View user's profile Send private message MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sun Jan 20, 2008 4:29 pm    Post subject: Reply with quote

Code:
printf("\n\nPress any key to continue...\n");
_getch();

return 0;
Back to top
View user's profile Send private message MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Jan 20, 2008 4:35 pm    Post subject: Reply with quote

noz3001 wrote:
Code:
printf("\n\nPress any key to continue...\n");
_getch();

return 0;


dont forget

Code:
#include <conio.h>

_________________
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: Sun Jan 20, 2008 5:43 pm    Post subject: Reply with quote

I wanted him to look that part up himself..
Back to top
View user's profile Send private message MSN Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

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

PostPosted: Sun Jan 20, 2008 6:41 pm    Post subject: Reply with quote

He'd have most likely just said something along the lines of

"Your code doesn't work!"

_________________
Wiccaan wrote:

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


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
wunder312355
Grandmaster Cheater
Reputation: -1

Joined: 14 May 2007
Posts: 568

PostPosted: Sun Jan 20, 2008 8:50 pm    Post subject: Reply with quote

samuri25404 wrote:
He'd have most likely just said something along the lines of

"Your code doesn't work!"


Im sorry, but i probably would have. That part just really confuses me. How do you know which files to include? Probably something to do with msdn right?
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: Sun Jan 20, 2008 11:16 pm    Post subject: Reply with quote

Don't worry, I most likely would have too. :P

You just kinda know, I guess. Microsoft grouped different things into different header files for a reason, though if you ever get confused, you just just Google it

_________________
Wiccaan wrote:

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


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
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: Mon Jan 21, 2008 2:30 am    Post subject: Reply with quote

thefun25 wrote:
samuri25404 wrote:
He'd have most likely just said something along the lines of

"Your code doesn't work!"


Im sorry, but i probably would have. That part just really confuses me. How do you know which files to include? Probably something to do with msdn right?


http://msdn2.microsoft.com/en-us/library/aa297934.aspx

Look, it tells you right there which headers to include.
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Jan 21, 2008 10:42 am    Post subject: Reply with quote

You shouldn't use System("pause"); for pausing your application if that is going to be the only System() call you make. This is due to creating a huge overhead for doing something basic.

Check out this article:
http://www.gidnetwork.com/b-61.html

For substitutes, you can use _getch(); or just use the iostream method of:

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


Code:
#include <iostream>

int main()
{
   std::cout << "Hello world!" << std::endl;
   std::cout << "Press any key to continue..." << std::endl;
   std::cin.ignore();
   std::cin.sync();
   return 0;
}



MegaForum wrote:
name space std;


Incorrect syntax, and this isn't needed. The correct method would be:

Code:
using namespace std;


Again, not needed though. And this wont cause the program to pause, it just signifies you want to use the std namespace so you do not need to make calls to the std functions inside iostream using std:: at the front.

A quick read if you want to know more about namespaces:
http://cplusplus.com/doc/tutorial/namespaces.html

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
MegaForum
Grandmaster Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 558

PostPosted: Mon Jan 21, 2008 7:39 pm    Post subject: Reply with quote

Wiccaan wrote:
You shouldn't use System("pause"); for pausing your application if that is going to be the only System() call you make. This is due to creating a huge overhead for doing something basic.

Check out this article:
http://www.gidnetwork.com/b-61.html

For substitutes, you can use _getch(); or just use the iostream method of:

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


Code:
#include <iostream>

int main()
{
   std::cout << "Hello world!" << std::endl;
   std::cout << "Press any key to continue..." << std::endl;
   std::cin.ignore();
   std::cin.sync();
   return 0;
}



MegaForum wrote:
name space std;


Incorrect syntax, and this isn't needed. The correct method would be:

Code:
using namespace std;


Again, not needed though. And this wont cause the program to pause, it just signifies you want to use the std namespace so you do not need to make calls to the std functions inside iostream using std:: at the front.

A quick read if you want to know more about namespaces:
http://cplusplus.com/doc/tutorial/namespaces.html


You wouldn't need st:: for ea. line if you just do
using namespace std; at the beginning right?
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jan 21, 2008 8:38 pm    Post subject: Reply with quote

including the entire namespace is pointless and is bad form
if your to lazy to add std:: to the beggining of all your cout's, cin's and endl's then just add this:

Code:
using std::cout;
using std::cin;
using std::endl;


you can add that instead because those are usually the only 3 things u use from the std namespace.

_________________
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: Tue Jan 22, 2008 5:59 am    Post subject: Reply with quote

MegaForum wrote:
You wouldn't need st:: for ea. line if you just do
using namespace std; at the beginning right?


Yes, if you include the namespace, you wont need the std:: in front of the functions and such, but my main reason for the response I quoted you with was because the code you gave was both written wrong and did not pertain to the question at hand.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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