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 


C++ error
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
crayzbeef
Expert Cheater
Reputation: 0

Joined: 21 Jan 2007
Posts: 101

PostPosted: Wed Aug 06, 2008 4:54 pm    Post subject: Reply with quote

DONT INCLUDE THE WHOLE NAMESPACE IF YOUR JUST USING COUT OR CIN!

using std::cout


or just say

std::cout << "Your all dumbasses learn C++ plz:
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Wed Aug 06, 2008 5:05 pm    Post subject: Reply with quote

I'm pretty sure VC++ still includes the iosteam.h file (Which doesn't use the std namespace). Also, main doesn't explicitly need to be int, it can be void but shouldn't be done really.
Back to top
View user's profile Send private message AIM Address MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Wed Aug 06, 2008 5:15 pm    Post subject: Reply with quote

jackyyll wrote:
I'm pretty sure VC++ still includes the iosteam.h file (Which doesn't use the std namespace). Also, main doesn't explicitly need to be int, it can be void but shouldn't be done really.


The compiler doesn't magically add includes. You have to include them yourself. If you want to use iostream, you must add it to your file(s) that are using it.

The main function for a console is 'int main' as standard. No it doesn't have to be int but that is C standard.

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

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Wed Aug 06, 2008 5:52 pm    Post subject: Reply with quote

Wiccaan wrote:
jackyyll wrote:
I'm pretty sure VC++ still includes the iosteam.h file (Which doesn't use the std namespace). Also, main doesn't explicitly need to be int, it can be void but shouldn't be done really.


The compiler doesn't magically add includes. You have to include them yourself. If you want to use iostream, you must add it to your file(s) that are using it.

The main function for a console is 'int main' as standard. No it doesn't have to be int but that is C standard.


I meant that the iosteam.h file is still included in the includes directory even though it's pretty much deprecated.
Back to top
View user's profile Send private message AIM Address MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Thu Aug 07, 2008 3:51 am    Post subject: Reply with quote

oib111 wrote:
How do you suggest then Jani?
I do NOT suggest pausing. The original poster didn't pause execution, but HalfPrime suggested that he should do that. I suggest that you DON'T pause execution. I was referring to pausing at the end of the program in general with the term "that way." Sorry for making my point a bit unclear.

Anyway.. If you MUST pause your program I second Wiccaan on that:
Code:
std::cin.sync();
std::cin.ignore();
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Thu Aug 07, 2008 9:34 am    Post subject: Reply with quote

And force people to run it through the console? No, thank you.
_________________
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Thu Aug 07, 2008 3:40 pm    Post subject: Re: C++ error Reply with quote

famousmassacre1 wrote:
i keep getting an error on this code but i cant find whats wrong
Code:

// This is a comment
// This program will accept and display their sum

#include <iostream.h>

void main()
{
 // Define variables
 float num1;
 float num2;
 float total;
 
 // Enter data for variables
 cout << "10";
 cin >> num1;
 cout << "9";
 cin >> num2;
 
 // Add the two numbers together
 total = num1 + num2;
 
 // Display the result
 cout << "The sum of the numbers = " << total;
 
}
[/code]


you forgot...

Code:
using namespace std;


or you'll haveto add...

Code:
std::


to your code.

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Thu Aug 07, 2008 3:44 pm    Post subject: Reply with quote

crayzbeef wrote:
DONT INCLUDE THE WHOLE NAMESPACE IF YOUR JUST USING COUT OR CIN!

using std::cout


or just say

std::cout << "Your all dumbasses learn C++ plz:


you mean

Code:
std::cout << "Your all dumbasses learn C++ plz"


REmember the ending quote. You need to brush up on your C++
Back to top
View user's profile Send private message Send e-mail
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Thu Aug 07, 2008 4:19 pm    Post subject: Reply with quote

kitterz wrote:
crayzbeef wrote:
DONT INCLUDE THE WHOLE NAMESPACE IF YOUR JUST USING COUT OR CIN!

using std::cout


or just say

std::cout << "Your all dumbasses learn C++ plz:


you mean

Code:
std::cout << "Your all dumbasses learn C++ plz"


REmember the ending quote. You need to brush up on your C++


You forgot your semi-colon, maybe you need to brush up too? Surprised
Back to top
View user's profile Send private message AIM Address MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Aug 07, 2008 4:23 pm    Post subject: Reply with quote

kitterz wrote:
crayzbeef wrote:
DONT INCLUDE THE WHOLE NAMESPACE IF YOUR JUST USING COUT OR CIN!

using std::cout


or just say

std::cout << "Your all dumbasses learn C++ plz:


you mean

Code:
std::cout << "Your all dumbasses learn C++ plz"


REmember the ending quote. You need to brush up on your C++


you mean

Code:
std::cout << "Your all dumbasses learn C++ plz";


REmember the ending semicolon. You need to brush up on your C++

also: you're
Back to top
View user's profile Send private message
Typhoon808
Expert Cheater
Reputation: 0

Joined: 27 Mar 2008
Posts: 175
Location: Wales

PostPosted: Thu Aug 07, 2008 4:26 pm    Post subject: Reply with quote

Also it's you're not your. Wink
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Aug 08, 2008 3:34 am    Post subject: Reply with quote

HalfPrime wrote:
And force people to run it through the console? No, thank you.
Running a program as a scheduled task and leave it waiting for input? No, thank you.

If you check any a bit more "professional" console program, you'll notice that they don't wait for a closing input. To name some programs (from M$ for example) help.exe, ipconfig.exe, rename.exe, and so on.. Note that we're talking about console applications.

Personally I run hella lot stuff from console, even programs with GUI. For example, my Firefox is running from console atm. And it's freaking annoying when you've to press any key to close a program.

PS: slovach & co.: you forgot to include the header containing std::cout object :P
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Fri Aug 08, 2008 8:34 am    Post subject: Reply with quote

We're not talking about scheduled tasks. We're talking about stand-alone console progs. They can be done either way, but 99/100 users would prefer press any key to exit.
_________________
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Aug 08, 2008 3:27 pm    Post subject: Reply with quote

HalfPrime wrote:
We're not talking about scheduled tasks.
It was just an example. Standalone console programs are widely used as scheduled tasks with some params.

Please mention any "professional" software requiring "press any key" at the end of execution. Just to name a few more programs, which close without nagging: fsum.exe*1, nmap.exe*2, lame.exe*3, rar.exe*4, java.exe*5, javac.exe*5, cl.exe*6... :) Actually to be honest, I can't figure out any "professional" program nagging about "press any key to exit" with an exception of bootloaders/BIOSes displaying an error message.

Only place where I'd like to have that nag is when your computer would restart after the nag -> the message couldn't be seen.

Because of Windows' XP (and Vista?) do have a feature of an auto closing cmd.exe doesn't mean that you should pause your program before exit.

HalfPrime wrote:
They can be done either way, but 99/100 users would prefer press any key to exit.
Guess if I made a poll here with people making their first hello world's, yeah that might be true. But go and make a poll, eg. on M$' newsgroup or some other forum with a bit more "experienced" people and you'll notice that it's totally the opposite.

References:
*1 http://www.slavasoft.com/fsum/
*2 http://nmap.org/
*3 http://lame.sourceforge.net/
*4 http://www.rarlab.com/
*5 http://java.sun.com/
*6 http://www.microsoft.com/
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