Any ideas? Its done this to me on many programs, but not the celsius one. I suspect I don't have something in place or there at all, but I dunno. Here's a sample of code I did this with(notice this is probably the most NEWB thing you've ever seen, but its me just testing the waters):
[WHO]ThemYou can call me DaveJoin Date: 2002-12-11Member: 10593Members, Constellation
<!--QuoteBegin-5kyh16h91+Jun 14 2004, 07:41 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (5kyh16h91 @ Jun 14 2004, 07:41 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> <!--QuoteBegin-[WHO+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> ([WHO)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->Them,Jun 14 2004, 09:29 PM] Just keep in mind that most of the time your code needs to be compiled into object files, and those object files need to be linked using a linker. <!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd--> How's about he compile the one .cpp file he has now before he tries to #include object files. I may have had a crappy book, but objects were in like chapter 14. He hasn't even gotten one program. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd--> /me smacks you over the head with a rolled up hat.
You don't #include object files, they're an intermediary step in the build process. If you go into the debug or release directory of almost any program you've compiled, you'll see a crapload of other files in there that you never made or asked for..... those are the object files.
and the extra parameters he has coming into main let you specify command-line arguments and are fine to completely ignore if they're there, or to remove entirely if you're not using them.
I read a book called "Teach yourself C++ in 21 days" when I was learning C++. It lasted me like a week or two then I just looked at code I found online (reading other people's code can help you a lot).
I had Borland C++Builder at the time and I was learning Delphi as well so I already knew a bit of the object/class type stuff. I also used the GNU C++ compiler for a while, back in my win98/DOS days I had DJGPP (which btw was awesome). I bought Visual C++ 6 after that - once I got into playing with HL I was hooked <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html//emoticons/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /><!--endemo-->
With regards to HL modding, the HL SDK is pretty scary at first if you don't know much C++ but just start reading thigns and trying to understand how they work (then you can make changes, like cranking up damage and rate of fire etc)
If you like, I'll dig through my backup cds at home and see if I can find any of my old code for you - I've got some simple programs I made ages ago which you may find useful...
<!--QuoteBegin-Quaunaut+Jun 15 2004, 11:35 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Quaunaut @ Jun 15 2004, 11:35 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Okay, bigger problem here. Something is wrong with <iostream.h>- every time I compile, this happens
There's no problem with your iostream library. The C++ compiler is smacking you on the nose with a rolled up newspaper for doing things the C way, rather than the C++ way. By the way, I'm fairly sure that that compiler message is a <i>warning</i>, rather than an <i>error</i>. Warnings don't halt compilation, but errors do (they're used when you do something slightly naughty, but not wrong enough to make it impossible to proceed).
The preferred way to use standard librries is:
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1--> #include <iostream> using namespace std; <!--c2--></td></tr></table><div class='postcolor'><!--ec2--> rather than <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1--> #include <iostream.h> <!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
The short answer: Try the first version, and I bet it'll stop your compiler complaining.
The long answer: This isn't just C++ being arbitrary out of malice. When you #include a header file, it effectively copies and pastes the contents of that file into your file. By changing the syntax to drop off the .h, C++ allows compiler makers to be smarter about #including stuff. Basically, it means that the iostream stuff might not physically be in a file called iostream.h, but instead in whatever cunning mechanism the compiler makers have used to make things more efficient.
The "using namespace std" bit is... well... you'll get there. Don't worry about it, it's just a way of making life easier.
Ok, if you <i>really</i> want to know, the short answer is that you either use
Oh, by the way, I've just read back over the thread. About your console apps closing too fast: some militant people will tell you to always always always run console apps from a command prompt, which avoids this problem. But practically speaking, if you don't want to do that, just use
You'll need <stdlib.h> or <cstdlib> #included, and it only works on Windows. What the <span style='font-family:courier'>system()</span> function actually does is runs the string as a DOS command, and the pause command prompts you to press any key to continue, then waits for you to press a key.
Try not to use it for anything other than putting it at the end of a test program to stop it from closing, though. It's not a standard, portable solution (so getting into the habit of using it all over your code is a bad idea), but as long as you understand that, it's fine.
<!--QuoteBegin-pielemuis+Jun 15 2004, 03:34 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (pielemuis @ Jun 15 2004, 03:34 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> you could add a cin.get() at the end, works on all platforms (make sure you don't have any newlines in the input queue left though). <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd--> Yes, but that's for "press <i>enter</i> to continue".
I haven't done it for years though, all my console programming is done on linux, at a real console so I don't need the "press any key to continue" stuff...
<!--QuoteBegin-SoulSkorpion+Jun 14 2004, 09:34 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (SoulSkorpion @ Jun 14 2004, 09:34 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Some general advice on learning C++:
"... for dummies" or "in 20 days" books are ok for a basic introduction, but you <i>need</i> better than that. There are two major problem with these books - firstly, they seldom last you more than 20 days. The other problem is more severe: they often teach you bad habits. What's a bad habit? Something that's non-standard, or something that's doing things the C way when there's a better and more painless version in the C++ way.
I highly encourage you to stick to standard C++ whenever possible, and to try to favour C++ constructs over C. It's not just being pedantic. In the long run, it'll make your life easier. I don't mean for you to constantly worry about whether your code is standard or not, but as you learn what is standard and what isn't, prefer the standard versions.
The other thing is that C++ is a <i>very</i> large language. There are a lot of keywords, and often keywords mean different things in different contexts. That's because C++ was designed to support several different, seperate programming concepts, and because it supports (nearly all of) C. Try not to be daunted by this, just learn the bits you need. Don't bother about templates, STL, classes, operator overloading, object orientation and all that mess until you're familiar and comfortable with the language itself. For the same reason, while Windows programming is a good thing to know, until you're comfortable and competant with the language itself, it's not going to help you much. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd--> ^^^ Listen to this man!
There is a really big problem w/ C++ books teaching non-standard code, such as the one you're using right now.
<!--QuoteBegin-Quaunaut+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Quaunaut)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Okay, bigger problem here. Something is wrong with <iostream.h>- every time I compile, this happens: <!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd-->
A good rule of thumb while you are still a beginner is NOTHING is ever wrong with iostream. C++ has been around for about 30 years, I don't think you're gonna find a bug in your first few weeks of coding it. :)
Usually if you fubar things up it can cause the compiler to tell you there are errors in iostream, but its really in your code. Happy digging.
<!--QuoteBegin-Quaunaut+Jun 14 2004, 10:15 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Quaunaut @ Jun 14 2004, 10:15 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> <!--QuoteBegin-Caboose+Jun 14 2004, 08:14 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Caboose @ Jun 14 2004, 08:14 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Like I said, the program worked, it just ended too fast for you to see the result. <!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd--> Hmm...time to downgrade to that Pentium 4 .000000000000000001ghz. <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html//emoticons/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /><!--endemo--> <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd--> Use:
QuaunautThe longest seven days in history...Join Date: 2003-03-21Member: 14759Members, Constellation, Reinforced - Shadow
<!--QuoteBegin-DOOManiac+Jun 16 2004, 03:42 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (DOOManiac @ Jun 16 2004, 03:42 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Well feel free to ask here too, as we also have quote capable coders here. Will give the poor chaps at Wavelength a break every once in awhile too. <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html//emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif' /><!--endemo--> <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd--> But DOOM, these guys are showing me how to do bump mapping and vertex shaders in a DOS-based 3d engine! Comon!
Sorry, bad flashbacks of actually having to make a software 3d renderer that supported bump maps. What a friggin headache!
Booo, hisssssssss. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd--> See, this is the code: We put it in DOOM. Every time you see a period, it puts a bump in there. So we took the brick walls, and just went
Link to the thread? <!--emo&;)--><img src='http://www.unknownworlds.com/forums/html//emoticons/wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /><!--endemo-->
Comments
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->1 C:\Documents and Settings\user\My Documents\customadd13.cpp
from C:/Documents and Settings/user/My Documents/customadd13.cpp
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->31 C:\Dev-Cpp\include\c++\backward\iostream.h
In file included from C:/Dev-Cpp/include/c++/backward/iostream.h
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
and it says something is wrong WITHIN iostream.h, with a line saying:
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->#include "backward_warning.h"<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
Any ideas? Its done this to me on many programs, but not the celsius one. I suspect I don't have something in place or there at all, but I dunno. Here's a sample of code I did this with(notice this is probably the most NEWB thing you've ever seen, but its me just testing the waters):
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->#include <iostream.h>
int main(int nNumberofArgs, char* pszArgs[])
{
int addthis;
cout << "This program will add whatever number you put here to 13:";
cin >> addthis;
int factor;
factor = addthis + 13;
cout << "addthis + 13 =";
cout << factor;
return 0;
}<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
<!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd-->
How's about he compile the one .cpp file he has now before he tries to #include object files. I may have had a crappy book, but objects were in like chapter 14. He hasn't even gotten one program. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
/me smacks you over the head with a rolled up hat.
You don't #include object files, they're an intermediary step in the build process. If you go into the debug or release directory of almost any program you've compiled, you'll see a crapload of other files in there that you never made or asked for..... those are the object files.
and the extra parameters he has coming into main let you specify command-line arguments and are fine to completely ignore if they're there, or to remove entirely if you're not using them.
I had Borland C++Builder at the time and I was learning Delphi as well so I already knew a bit of the object/class type stuff. I also used the GNU C++ compiler for a while, back in my win98/DOS days I had DJGPP (which btw was awesome). I bought Visual C++ 6 after that - once I got into playing with HL I was hooked <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html//emoticons/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /><!--endemo-->
With regards to HL modding, the HL SDK is pretty scary at first if you don't know much C++ but just start reading thigns and trying to understand how they work (then you can make changes, like cranking up damage and rate of fire etc)
If you like, I'll dig through my backup cds at home and see if I can find any of my old code for you - I've got some simple programs I made ages ago which you may find useful...
......
<!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd-->
Hehe <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html//emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->
There's no problem with your iostream library. The C++ compiler is smacking you on the nose with a rolled up newspaper for doing things the C way, rather than the C++ way. By the way, I'm fairly sure that that compiler message is a <i>warning</i>, rather than an <i>error</i>. Warnings don't halt compilation, but errors do (they're used when you do something slightly naughty, but not wrong enough to make it impossible to proceed).
The preferred way to use standard librries is:
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
#include <iostream>
using namespace std;
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
rather than
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
#include <iostream.h>
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
The short answer:
Try the first version, and I bet it'll stop your compiler complaining.
The long answer:
This isn't just C++ being arbitrary out of malice. When you #include a header file, it effectively copies and pastes the contents of that file into your file. By changing the syntax to drop off the .h, C++ allows compiler makers to be smarter about #including stuff. Basically, it means that the iostream stuff might not physically be in a file called iostream.h, but instead in whatever cunning mechanism the compiler makers have used to make things more efficient.
The "using namespace std" bit is... well... you'll get there. Don't worry about it, it's just a way of making life easier.
Ok, if you <i>really</i> want to know, the short answer is that you either use
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
#include <iostream>
using namespace std;
int main()
{
?cout << "hi" << endl;
}
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
...or...
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
#include <iostream>
int main()
{
?std::cout << "hi" << std::endl;
}
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
Yes, there's a point. Again, don't worry about it yet.
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
system("pause");<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
You'll need <stdlib.h> or <cstdlib> #included, and it only works on Windows. What the <span style='font-family:courier'>system()</span> function actually does is runs the string as a DOS command, and the pause command prompts you to press any key to continue, then waits for you to press a key.
Try not to use it for anything other than putting it at the end of a test program to stop it from closing, though. It's not a standard, portable solution (so getting into the habit of using it all over your code is a bad idea), but as long as you understand that, it's fine.
Yes, but that's for "press <i>enter</i> to continue".
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
while (!getch());
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
I haven't done it for years though, all my console programming is done on linux, at a real console so I don't need the "press any key to continue" stuff...
"... for dummies" or "in 20 days" books are ok for a basic introduction, but you <i>need</i> better than that. There are two major problem with these books - firstly, they seldom last you more than 20 days. The other problem is more severe: they often teach you bad habits. What's a bad habit? Something that's non-standard, or something that's doing things the C way when there's a better and more painless version in the C++ way.
I highly encourage you to stick to standard C++ whenever possible, and to try to favour C++ constructs over C. It's not just being pedantic. In the long run, it'll make your life easier. I don't mean for you to constantly worry about whether your code is standard or not, but as you learn what is standard and what isn't, prefer the standard versions.
The other thing is that C++ is a <i>very</i> large language. There are a lot of keywords, and often keywords mean different things in different contexts. That's because C++ was designed to support several different, seperate programming concepts, and because it supports (nearly all of) C. Try not to be daunted by this, just learn the bits you need. Don't bother about templates, STL, classes, operator overloading, object orientation and all that mess until you're familiar and comfortable with the language itself. For the same reason, while Windows programming is a good thing to know, until you're comfortable and competant with the language itself, it's not going to help you much. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
^^^ Listen to this man!
There is a really big problem w/ C++ books teaching non-standard code, such as the one you're using right now.
<!--QuoteBegin-Quaunaut+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Quaunaut)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->
Okay, bigger problem here. Something is wrong with <iostream.h>- every time I compile, this happens:
<!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd-->
A good rule of thumb while you are still a beginner is NOTHING is ever wrong with iostream. C++ has been around for about 30 years, I don't think you're gonna find a bug in your first few weeks of coding it. :)
Usually if you fubar things up it can cause the compiler to tell you there are errors in iostream, but its really in your code. Happy digging.
Hmm...time to downgrade to that Pentium 4 .000000000000000001ghz. <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html//emoticons/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /><!--endemo--> <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
Use:
system("pause");
In your code to have it pause before it exits
Sorry! If need be you guys can lock the thread, being I've been promised help at Wavelength. <3
But DOOM, these guys are showing me how to do bump mapping and vertex shaders in a DOS-based 3d engine! Comon!
Sorry, bad flashbacks of actually having to make a software 3d renderer that supported bump maps. What a friggin headache!
Booo, hisssssssss.
Sorry, bad flashbacks of actually having to make a software 3d renderer that supported bump maps. What a friggin headache!
Booo, hisssssssss. <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
See, this is the code: We put it in DOOM. Every time you see a period, it puts a bump in there. So we took the brick walls, and just went
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->.............................................................................................................................................................................................................................................................................................................................................................;<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
That produced this:
<img src='http://pcmedia.gamespy.com/pc/image/6198_2004-03-22_04.jpg' border='0' alt='user posted image' />
See, even changed textures and everything!
On a more serious note: I'm learning about decisions and stuff now. w00t w00t.