³ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄij +-+-+-+-+-+-+-+-+ ÛÛÛÛÛÛÛÛÛ²²²²²±±±±±°°°ð|O|u|t|b|r|e|a|k|ð°°°±±±±±²²²²²ÛÛÛÛÛÛÛ +-+-+-+-+-+-+-+-+ Issue #3 - Page 8 of 12 ³ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄij Radioactive_Raindeers guide to C/C++ programming. Part 1 - The basics. This is supposed to be a basic guide to C/C++ programming. When someone writes this kind of guide he/she is usually flooded with more questions from newbies and comments and flames form the real pros. So I'll just ask you now: Please don't mail me! Not that I'd really mind. It's just that I probably wouldn't answer. You're better off asking questions on IRC and sending your flames to /dev/null on your local system. I'll start this off with explaning the basic syntax of a program containing only one function and no variables. If you don't know what I'm talking about don't worry. It'll all be clear after you've read this. Here's the program: <---- code start ----> #include int main(void) { cout << "ph33r me for I am text."; cout << "\n"; return 0; } <----- code end -----> Easy, eh? For those of you who disagree I'll explain each line as clearly as I can. #include The pound (#) tells the program that it's a pre-processor directive. (More about those in another article.) This one tells it to include the functions in the file 'iostream.h' for use in this program. int main(void) { This line contains two important things. First it's the actual function and the second a left curly bracket. A function started off with the type of varible is returns. In this case it's an integer, followed by the name of the variable and the parameters to the function inside parenthesis. The second part, the left curly bracket tells the compiler that from now on the code belongs to this function. cout << "ph33r me for I am text."; This line sends the text inside the double quotes to standard output. This is the reason that we included iostream.h earlier. cout << "\n"; Same as above. But \n is a symbol for a new line. return 0; Returns a value to the caller of the function. In this case it would be the operating system. } This right curly bracket tells the compiler the the function stops here. Don't worry too much if you don't understand all of this right now. It will come to you later on. I'll talk a bit about varibles now. A variable is a C/C++ entity that contains something. A number, a character, an object, an adress to another variable, etc. I'll just go over the basic ones right now though. int Contains an integer (a whole number) Examples: 7, 132, 95, -35, 0 char Contains a character Examples: A, g, 6, ?, < bool Contains either true or false. (Only available in ANSI/ISO C++ compatible compilers.) float Contains non integer numbers (Numbers with decimals) Examples: 3.14, 12.34, 9.11e-31, -7.36 void A special type of variable. Basically just a variable placeholder where you have to have a variable according to the syntax but you don't need one in your program. Since I want to keep this readable I'll stop here and continue in the nex issue. Then I'll talk a little more about functions and even more about varibles. =) Can't wait, eh? That's all from me for now. / Radioactive_Raindeer r_r@diegeekdie.org