void* or function?

Posted By: NeoNeper

void* or function? - 02/25/13 16:04

what is the difference between void * and function?
When should I use void * and when should I use function?
Posted By: Uhrwerk

Re: void* or function? - 02/25/13 16:17

These are two different data types. "function" means that you return a var/fixed variable. "void*" means that you want to return a pointer to something. I'll give you an example:
Code:
function foo()
{
   return 1.337; // Alright
   // return bmap_create("lol.dds"); Not ok. foo should return a number.
}

void* bar()
{
   // return 1337; Don't do this. You should return an address.
   return &video_mode; // Ok. void* is correct. int* would be even more precise.
}


Also see the manual concerning data types.
Posted By: Ch40zzC0d3r

Re: void* or function? - 02/25/13 16:18

Originally Posted By: NeoNeper
what is the difference between void * and function?
When should I use void * and when should I use function?


First of all, void * and void is a difference.
void * can return a pointer, void not. Also function can always return something, so it seems that function is something like var.
Posted By: Uhrwerk

Re: void* or function? - 02/25/13 16:23

Originally Posted By: Ch40zzC0d3r
so it seems that function is something like var.
grin

Function is not something like var, it is exactly var. It all comes down to the fixed type. var is fixed and function is var. You can see all this in acknex.h.
Posted By: NeoNeper

Re: void* or function? - 02/25/13 16:25

Ohhhhh i Understand. Tanks mans.
I'll review my scripts from now on!
I used functions for all LOL!
Posted By: Wjbender

Re: void* or function? - 03/07/13 19:57

Originally Posted By: Ch40zzC0d3r
Originally Posted By: NeoNeper
what is the difference between void * and function?
When should I use void * and when should I use function?


First of all, void * and void is a difference.
void * can return a pointer, void not. Also function can always return something, so it seems that function is something like var.


type name (parameter1, parameter2, ...) { command1; command2; ... }
type is the type of the variable (such as var, int, float...) that the function returns to the caller. If the function returns a var, or returns nothing, you can write just function instead of the type.
..............
void:
When used as a function return type, the void keyword specifies that the function does not return a value. When used for a function's parameter list, void specifies that the function takes no parameters.

void*:
A void pointer can be converted into any other type of data pointer.
© 2023 lite-C Forums