Thread: Void, return... and what to use for 2D games?

1. Void, return... and what to use for 2D games?

Hello! Its my first post here in C Board... I have been using Cprogramming.com quite alot, and it really helped me, although there are still a coupla C codes I still don't understand, nor use.

I have always been wondering, what is Void for, and return about.
A.k.a
Code:
```void hello();

/* and */

return 0;```
What does it mean when you "return a value" ?

Also, I have a project, Tetris from my ex-teacher. Programming is not really a subject in my school, but an extra activity under a info-media club. I am trying to start with OpenGL, but stupid me, I can't really know what the different codes are about. Are there any recommended websites that do OpenGL in C(if there is, or Win32 if not), and also for 2D graphics? Or perhaps some new kinds, like SDL or whatever there are? Lol.

Merry Christmas, and thank you!

2. void function is a function that does not return a value

return statement is used to return a value from the function and end its flow

like:
Code:
```int sumOfInts(int a, int b)
{
return a+b;
}```
It can be used in the followint way:
Code:
```int main()
{
int sum = sumOfInts(3,5);
printf("sum of 3 and 5 is %d", sum);
return 0;
}```

3. Are there any recommended websites that do OpenGL in C
OpenGl programming

This is E-book. Which teaches you everthing about OpenGL

ssharish2005

4. Oh, thank you both! ^_^.

If its possible, just one last check ->

Code:
`a = a + 1`
is not a return value, right?

5. did you mean something like this

Code:
```void func(int a)
{
a = a+1;
}```
this function doesn't return a value. but this does

Code:
```int func(int a)   // not the return type which basically specifying that u are return a value of type int
{
return a = a+1;   //  in this case the expression will be evaluated first and the the value of 'a' will be returned. this statement can Else be written-ed as return a+b  as well
}```
hope this helps

ssharish2005

6. Ok. Thanks alot. It cleared up everything ^^

7. Check out the tutorials, specifically, this one: http://www.cprogramming.com/tutorial/c/lesson4.html

Though admittedly the only mention I can see of return values is this.
When I say that the function returns a value, I mean that the function can be used in the same manner as a variable would be. For example, a variable can be set equal to a function that returns a value between zero and four.
For example:
Code:
```#include <stdlib.h>   /* Include rand() */

int a = rand(); /* rand is a standard function that all compilers have */```
Do not think that 'a' will change at random, it will be set to the value returned when the function is called, but it will not change again.

The general format for a prototype is simple:
Code:
`return-type function_name ( arg_type arg1, ..., arg_type argN );`