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 


New to C++
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Acim
Grandmaster Cheater Supreme
Reputation: 0

Joined: 04 Jun 2007
Posts: 1948
Location: If anyone has a GMS DK and they don't need it I'll have it!!

PostPosted: Fri Oct 05, 2007 2:34 pm    Post subject: New to C++ Reply with quote

Yeah... I'm new to C++. So I've used a compiler (Bloodshed Dev-C++) and for the program I wrote:

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

I also tried int main( void ) and stuff like that, but when it runs it immediatly closes. In BAT programming "pause" makes it stay and not close until the exit button is hit, is there any C++ command that does that?

_________________
I'm alive and well, but I quit CEF for a while. Legitly playing since Novemberish 07. Starting hacking October 06.
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 05, 2007 2:50 pm    Post subject: Reply with quote

__getch();

edit: i think you need to include conio for it.
Back to top
View user's profile Send private message
zart
Master Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 351
Location: russia

PostPosted: Fri Oct 05, 2007 3:07 pm    Post subject: Reply with quote

system ("pause");

http://www.bloodshed.net/dev/faq.html

_________________
0x7A 0x61 0x72 0x74

TEAM RESURRECTiON
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Oct 05, 2007 3:13 pm    Post subject: Reply with quote

Code:
std::cin.ignore();
std::cin.sync();
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Oct 05, 2007 3:14 pm    Post subject: Reply with quote

I posted this in the RS section when he asked for it there, I am just reposting here just incase anybody else was wondering:

Mychilli wrote:
Code:
#include <iostream> // provides std::cout
 
int main()
{
    std::cout << "Hello, world!\n";
    return 0;
}


lol spoilers


Using a namespace is like globally defining the class you use, so std::cout was the exact same thing he was doing.

You are actually doing everything correctly (aside form the fact it is in C++). What the program does it output Hello, world! then immediately closes. What you want is a way to either prolong the closing or wait till the user hits a key.

Prolong:
Code:
#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World! xD";
Sleep(1000); //The program waits for 1000ms (1 second) before continuing.
return 0;
}


Wait for input:
Code:
#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World! xD";
cin.get(); //Wait for keypress.
return 0;
}
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Oct 05, 2007 3:25 pm    Post subject: Reply with quote

Flyte wrote:
Wait for input:
Code:
#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World! xD";
cin.get(); //Wait for keypress.
return 0;
}
Code:
#include <iostream>

int main(int argc, char* argv[])
{
  std::cout << "Hai World!";
  std::cin.ignore();
  std::cin.sync();

  return EXIT_SUCCESS;
}
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Oct 05, 2007 3:28 pm    Post subject: Reply with quote

Flyte wrote:
x0r wrote:
I didn't know iostream provided it's own Sleep function Laughing


My bad, too many C programming habits. Laughing
You know what I was getting at though.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Oct 05, 2007 4:36 pm    Post subject: Reply with quote

Lol, so many people having trouble with this. You can't put return 0. Do this.

Code:

#include <iostream>

using namespace std;

int main()
{
   cout<<"Hello World!\n";
   cin.get();
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Oct 05, 2007 4:38 pm    Post subject: Reply with quote

oib111 wrote:
Lol, so many people having trouble with this. You can't put return 0. Do this.

Code:

#include <iostream>

using namespace std;

int main()
{
   cout<<"Hello World!\n";
   cin.get();
}


NO!
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Oct 05, 2007 4:56 pm    Post subject: Reply with quote

Fine remove the namespace, its not good programming practice right Rolling Eyes
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Oct 05, 2007 4:58 pm    Post subject: Reply with quote

oib111 wrote:
Fine remove the namespace, its not good programming practice right Rolling Eyes


Ahahaha, that isn't why I said no.

Always have a return in main!
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Oct 05, 2007 5:12 pm    Post subject: Reply with quote

Lol. Or void it. But you rly shouldn't void it.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

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

PostPosted: Fri Oct 05, 2007 5:38 pm    Post subject: Reply with quote

oib111 wrote:
Lol. Or void it. But you rly shouldn't void it.


Or double it or char it or rape it. namespace std; isn't bad programming!
Back to top
View user's profile Send private message MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Fri Oct 05, 2007 5:43 pm    Post subject: Reply with quote

noz3001 wrote:
Or double it or char it or rape it. namespace std; isn't bad programming!


It's bad beginner programming, especially if you don't know what it means or what namespaces are. What if there was a function inside the std namespace called MessageBoxA? Since you dumped the contents of std into the current namespace, when you use MessageBoxA, you use the std one, not the windows one (well maybe it wouldn't if the parameters were different, but namespaces should be used to solve naming conflicts, not cause them!)
Back to top
View user's profile Send private message
Acim
Grandmaster Cheater Supreme
Reputation: 0

Joined: 04 Jun 2007
Posts: 1948
Location: If anyone has a GMS DK and they don't need it I'll have it!!

PostPosted: Sun Oct 07, 2007 10:58 am    Post subject: Reply with quote

appalsap wrote:
noz3001 wrote:
Or double it or char it or rape it. namespace std; isn't bad programming!


It's bad beginner programming, especially if you don't know what it means or what namespaces are. What if there was a function inside the std namespace called MessageBoxA? Since you dumped the contents of std into the current namespace, when you use MessageBoxA, you use the std one, not the windows one (well maybe it wouldn't if the parameters were different, but namespaces should be used to solve naming conflicts, not cause them!)

Appal ur slightly confusing... Im gonna try some of these.

Oh and C++ book says use the freakin BAT file but it doesnt work so... Very Happy

_________________
I'm alive and well, but I quit CEF for a while. Legitly playing since Novemberish 07. Starting hacking October 06.
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 1, 2  Next
Page 1 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