Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Getting started

This topic is 5679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

ok i have the tools Graphics 3dmax photoshop paintshop compiler dev C++ what esle do i need i also need after i i have the tools where do i start? i think i need a map editor thanks

##### Share on other sites
hehe, wtf?

what is your goal? do you want to make a game? if so, start learning how to program C++, then learn a graphics API to load your graphics!

.COM .NET - fimiliar?

[edited by - Pipo DeClown on November 2, 2002 6:33:37 AM]

##### Share on other sites
what does this mean ?

#include <stdio.h>

int main(int argc, char *argv[])
{

return 0;
}

##### Share on other sites
you could try to get Microsoft Visual Studios 6.0 or higher its good too and read the articles here learn C / C++

##### Share on other sites
plz start here : http://www.gamedev.net/reference/start_here/

##### Share on other sites
You have the tools, that''s a start. But you could have thinked of it that now you have them, you need to learn how they work

3dsmax is a beautiful programm and but you first need to learn how it works before you can make anything.

The compiler you have compiles C++ code so you need to learn how to write this code..

##### Share on other sites
It''s your basic C program and it does nothing - literally. It starts up, hits the "return" statement, and then finishes with an exit code of 0.

Here''s a line-by-line appraisal:

#include <stdio.h>

If you want to use functions/variables, you have to ensure that they are included at top of the relevant file. This can be done using the #include statement. In this case, the file stdio.h, which will be in the default library path for your compiler, is being included. This header file has lots of available functions for you to use, such as "printf". They will come in handy later on.

Have a look here and find the "stdio.h" reference. In this case, the program isn''t actually using any functions in it, but it can later on.

Everything that you use exists somewhere. If it''s not in the current file then you have to include the file so that its existence is known (the compiler will throw a wobbly if it doesn''t know about it).

int main(int argc, char *argv[])

This is the start of a function. In this case it''s a function called main, which has a special property - the action starts here (it''s the first function you wrote that gets called). A function returns a value. The syntax for a function is:

"return_type function_name(arguments)"

There are many basic primitive types such as int (an integer, i.e., a whole number (positive or negative), a char (a character), etc.). The arguments are separated by commas for each one, and follow the format "data_type parameter_name" (e.g. "int argc"). Unfortunately, the ones to main are rather cryptic. To get a better grasp of how this works, imagine the following...

You want to write a function that adds two numbers together and returns the result. Your function would have a return type, a name and some parameters (two in this case). It could start off looking like this, for example: "int AddMyNumbers(int firstNumber, int secondNumber)". That says "this is a function called AddMyNumbers. It expects two numbers to be passed in, which can be referenced as ''firstNumber'' and ''secondNumber'' inside of the function code. When it''s finished, it will give back a value, which will be a number, using the ''return'' statement".

The two arguments to the main function are argc, which is a number. This stores the amount of command-line parameters passed in. Argv is an array of words passed in (i.e., what the command-line parameters themselves were).

If you don''t want to include arguments to a function, you can use "void" instead (e.g. int MyFunction(void)). This simply means "there are no parameters". Similarly, you can use void as the return type. This simply states that your function won''t return anything at all: "void MyFunction(void)"

The curly braces { } indicate the start and end of a block. Whenever you want to group values together, you use curly braces. This means that the code will get treated as belonging to the same part. All the lines of code in this function (main) belong to it. To see why curly braces are needed, consider these lines of code:

  if (something)  doFirstThing(); // calls a functiondoSecondThing(); // another function call

The above code would call the doFirstThing() function if something was true. It would always call the second function too, though, because the if statement only has one line of code attached. If you wanted both to run if the condition was true, you could do this:

  if (something){  doFirstThing(); // calls a function  doSecondThing(); // and other function call}doAThirdThing();

The curly braces indicate that both statements belong inside that if statement. Each statement will get executed inside the braces in turn, until the end is reached. This means that if the statement is true, both doFirstThing and doSecondThing will be executed.

return 0;

This line of code returns a value from the functions. All functions must return something (in this case, a number). The syntax is simply "return something;" Something must evaluate to the same type that''s expected to be returned. So, for example, you could do this for an integer: "return 2+2;" However, you could not do this: "return 32.2" - that value isn''t a whole number, so you''d need a different return type (a float or double in this case) that could handle such numbers.

If your function doesn''t return anything (i.e., it''s declared as ''void'') then you omit the extra part and simply say "return;".

Any return statements jump out of the given function immediately.

##### Share on other sites
Here''s a line-by-line appraisal:

#include <stdio.h>

If you want to use functions/variables, you have to ensure that they are included at top of the relevant file. ????????????????

this has to be at the top of everthing u code?

int main(int argc, char *argv[])

This is the start of a function. In this case it''s a function called main, which has a special property - the action starts here (it''s the first function you wrote that gets called). A function returns a value. The syntax for a function is:

so this goes to the compiler

int main(int argc, char *argv[]) and then gets returned?

##### Share on other sites
quote:
Original post by Anddos
this has to be at the top of everthing u code?

It depends... If you don't use any functions that are written in other files, you don't need any #include statements either. What you include depends on what functions you need.

Suppose you were using a function called "FuncOne()" and it was written in the file "MyFunc.h". You could include it like this:

        #include "MyFunc.h"int main(void){    FuncOne();    return 0;}

If you were using several functions, you could #include for each of the relevant files:

  #include "MyFunc.h" #include "Another.h"int main(void){    MyFunc();    AnotherFunc();    return 0;}

Each header file can contain one or more functions. When you #include it, you get access to all the functions inside it. If you don't #include it then there's a good chance that your program won't compile (or it might with a warning).

There's a small complication here. If you want to #include a library file (in your compiler's lib directory somewhere) then you use angled brackes: #include <b><stdio.h>, for example. The file stdio.h is sitting in the main compiler library directory. If you want to include a file you wrote yourself, you use double-quotes: #include "myfile.h". This checks in the current directory for a file called myfile.h, which you would have written. You can't use angled brackets there unless you put that file in your compiler's lib directory, which is a bit of a pain, so you don't bother most of the time.

quote:

so this goes to the compiler

All the code you write gets compiled (except for the comments, which is the reason they exist - so that you can write in natural English at times for better explanation). The main() function, though, is the first one that gets executed. The program needs somewhere to indicate where to start. With a console program (you'll see a "dos-box" opening up), the first code that you write to get executed is the main() function). If you're writing a win32 program then it needs to be called WinMain() instead.

If you wrote this, for example, with two functions:

  void someFunc(void){  /* put some code in here */}int main(void){  someFunc(); /* first line of code to be executed */  return 0;}

...then when the program runs, the first action it takes is to go inside the main function, since that's why you have to write it! It runs top-down. In this case, it will start by going to the first line of code that says "someFunc()". This, in turn, is a function call. It's saying stop doing what you're doing and go to this function instead! We've written a function called someFunc, so we call it by writing its name in code and passing any required arguments. In this case, there are no arguments required, so we leave the brackets empty. Once it's finished doing that function, it will return to the next line of code (return 0) and the program finishes.

[edited by - Alimonster on November 2, 2002 7:56:20 AM]

• 10
• 18
• 14
• 18
• 15