The reason for this is simple: malloc returns void* and not int*.While in C it's legal to assign void* to int* without a cast, in C++ it isn't.. Why the difference? Void means nothing. Further, these void pointers with addresses can be typecast into any other type easily. You can also use void as a referent type to declare a pointer to an unknown type. void Write () Program presents an example where a void function is defined to display a message. One should stop using the ‘void … If a function is defined as “ void ” it does not need to return a value. void means that this method does not have a return value. The first is a function that prints information for the user to read. C# reference; System.Void The C library function void *memchr(const void *str, int c, size_t n) searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str. Using the return statement in void functions Note that in the example above we didn’t need to use the return statement in the main function. Functions 2: Void (NonValue-Returning) Functions. Such functions return control automatically when they reach the end of their body. The void keyword has a third (more advanced) use in C++ that we cover in section 9.20 -- Void pointers. See also. You will learn more about return values later in this chapter You will learn more about return values later in this chapter Note: In C#, it is good practice to start with an uppercase letter when naming methods, as it makes the code easier to read. Home » C » Pointer » Void Functions in C. ... ("You need a compiler for learning C language.\n"); } The first line in the above definition may also be written as. while creating methods we mention whether a method has to return something after executing the block of code enclosed in it or not (Void). Well, let us start with C. The official "bible" of C, "The C Programming Language, 2nd edition" by Kernighan and Ritchie states in section A.6.8: Any pointer to an object may be converted to type void* without loss of information. Void (NonValue-Returning) functions: Void functions are created and used just like value-returning functions except they do not return a value after the function executes. void main – The ANSI standard says "no" to the ‘void main’ and thus using it can be considered wrong. For example (for our purposes), the printf function is treated as a void function. One should stop using the ‘void main’ if doing so. A void pointer in C clearly indicates that it is empty and can only capable of holding the addresses of any type. For more information, see Pointer types. Since we haven’t covered what a pointer is … Declaration. In lieu of a data type, void functions use the keyword "void." Definition of C Void Pointer. Void functions are mostly used in two classes of functions. Following is the declaration for memchr() function. You cannot use void as the type of a variable. A void pointer in C is a pointer that does not have any associated data type.