Alcohol and calculus don’t mix. Never drink and derive.
0 Members and 1 Guest are viewing this topic.
/* Welcome to the first chapter of this book. I will teach you how to program from the ground up (excluding setting up projects) in the way I learn best. In my opinion, hands on examples you can modify are the best methods to teach a new concept. Because of this, the tutorials will follow a very simple set of rules. 1. Only new code will be commented. This keeps the code clean and less confusing. 2. All tutorials will be short and to the point. Tutorial one will have the most amount of comments since it is also introducing syntax which is harder to show more often then explain. 3. There are NO errors in this code. If your code is not compiling, then you most likely made a typo. All tutorials and text in this book is precompiled before being entered into PDF format to ensure code accuracy. 4. Tutorials are designed for a Windows machine. This does not mean the tutorials do not transfer over to other platforms. It means that these tutorials have been tested specifically on a Windows machine. Programming concepts and the majority of these tutorials can be carried over to a Linux distro or a Mac machine. 5. All tutorials have a help page. All tutorials presented in this book have a website equivilent. If you have questions pose them to the site included in each lesson. 6. All tutorials have a project to go with them. If you have downloaded this book from online source aside from our site (http://Www.CelestialCoding.com) then there is a chance the code is not included. This books newest version can be downloaded from our site as well as the source code to go along with it. 7. All tutorials are geared toward games. This keeps the interest alive as well as shows real world examples. With that, welcome to programming, lets start on lesson 1...*/
/* In programming, there are different ways to teach. One way is to have you read a book and test you at the end. Another is by hands on examples. I prefer the latter of the two teaching philosophies. This sentence you have been reading is called a 'Block Comment.' Notice how it starts with a \* and ends with a * /. This type of comment allows for multiple lines of comments to occur.*///// This is a single line comment. Anything typed after the double slash is considered to be// a comment. This will allow us to do line by line commenting which will be the bulk// of the comments you read in the following tutorials.//#include <iostream> // Include the contents of iostream/* #include <> The include keyword is what we call a preprocessor command. The IDE will replace this command with the contents of the file we asked for. It essentially copies and pastes the file above all the code below. There are two ways to use the #include keyword. One way, which we used above, is to use the greater than and less than symbols. This means the file we are requesting is located in the default folder set by your IDE. When installing a IDE, all the default files are copied automagically into this location. The other way to use the keyword is quotation marks. For example #include "myCustomHeader.h" The quotations tell the IDE that the file is located in the project folder. This is what you will use most often for when you create custom header files for your projects.*/int main() // Main program entry with no parameters. Returns a type of int. Functions will be covered later.{ // Opening bracket for function main() std::cout << "Hello world!" << std::endl; /* std::cout << "..." << std::endl; This is what is called a stream. For now, think of this as a way to print output to the console window. The command is made up of multiple parts explained below. std:: This is what we call a namespace. The namespace is essentially a container that holds variable types and commands that should be divided from other code chunks. To use code from inside these namespaces, you have two options. The first is to use the way we did above. This keeps your code nice and clean if you only have a few commands from that namespace to use. The otherway is to declare that you will be using that namespace and you can then leave out the std:: and simply type 'cout << ...'. cout << "..." << std::endl; cout is a command we use to print data to the screen buffer. This can also print to a stream variable, but that is beyond the scope of this initial lesson. The '<<' symbol shows the flow of data. You can think of it as this anyhow since you will not by modifying this anytime soon in these tutorials or even in real life. Following the '<<' is the string "Hellow world!". This should be self explanitory. We then have another '<<' which is just stating that more data is following the previous. 'std::endl' quickly follows. We cna remove the std:: since that is the namespace that contains the endl command. 'endl' simply means "endline." It allows us to have the equivilent of an enter press and move down to the next line in the console window. ; ALL STATEMENTS END WITH A COLON. Conditional loops, defines, macros, and functions are the only exception to this rule. That is all. */ return 0; // return 0 meaning 0 errors} // Closing bracket for function main() /* *********************** NOTE ************************* If your program flickers very fast, it is because it is running and exiting very quickly. Many IDEs will prevent a automatic close while in debugging mode. If you intend to use release mode, the code for pausing a program is located in the next lesson.*/
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
I'd prefer to die standing, than to live on my knees - Che Guevara
If you change the way you look at something, does that something change in any way? - Quantum Theory
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.
It takes skill to build an empire. It takes an idiot to maintain it.
Very nice.However, I find that reading a book is the superior way. But that just might be me.
You can waste loads of time trying to do something that's already been perfected many times over.
Speaking of which.. I've been trying to find a book that isn't 20 years old, that can help me out with windows programming. MSDN is great, but it pretty much has all three of those downfalls. And on top of that, they keep trying to push everyone to use some form of directx or mfc or other library. I would really just like a reference to the underlying code. No library that was created to make everything abstract and easy.edit: This look like a good book? "Windows System Programming (4th Edition)"