[A83] Re: C(++) programming
[Prev][Next][Index][Thread]
[A83] Re: C(++) programming
Hi!
> Somebody in to C(++) programming??
I hope so! :)
> What's the difference between "int main()" and only "main()"??
main () is the function the processor jumps to when the application is
started. In C/C++ function prototypes can look like this:
function datatype function name (parameter1 datatype, parameter2 datatype);
int main(); would mean that the function returns an integer and its name is
main (which is a very special function) and the function has no parameters.
The number of parameters is practically unlimited and can also be variable
when you define a function for example like this:
void draw(int, unsigned char, ...)
the "..." indicates that the function has a variable number of parameters.
void is a datatype in c/c++. a void function can not return a value.
another important thing is that on the left side and on the right side of a
command there has to be the same datatype, for example:
long add(int, int); // define function which returns a long value
long sum; // define long variable named sum
int a = 4514, b = -941; // define the 2 parameters of add
sum = add(a, b); // store the value returned by add to sum
the standard datatype of a function in ANSI C is int. so "int main()" and
"main()" don't make any difference. i wouldn't leave out the datatype
because this is no good programming style and can cause big problems
especially when you are working with compilers that are not 100% ANSI C
compatible.
> And what is "return0;" for? Something like returning to the OS like
this is the value a function return (in this case 0). this can also be a
character or a string or something else.
the main function normally returns the value to the OS.
> Could sombody give me a good address where I can find some good C (++)
> tutorials??
No, sorry.
HTH
Andi
References: