What is void type and how does it work?

I almost finished my C Primer Plus book, and I'm going to click Structures and Unions, etc. etc., but I still don't understand what exactly the void keyword means. What does emptiness do? How it works? And when should I use it?

I understand that

void function(void)

basically says no return value. no arguments. I know that you can use different scenarios,

int function(void); //has a return of type int -- voids args
void function(int); //voids return type -- takes type int as an arg

I also understand that

void * p = 0L;

is valid code and that it is basically a pointer to void with an initialized value of length 0.

but is there any meaning or purpose to use it that way

void k = 0;

? , - ? , , ,

size_t fwrite(const void * restrict ptr, ...more args...);

, " catchall " "Pre-ANSI C char * , ".

, ? , ?

... , int void. , --void , , . , " ?" " ?".

.

+4
2

-

void k = 0;

, , . , , void, , *, , :

void *foo = nil;

, foo - , , foo. * , , ( , ).

, " catchall "

- " " - - . , , , , .

, ?

. fwrite() , , , . fwrite() , , .

+6

, void. , - , void, , 99% .

, , "" " ", " ".

1) , , , .

2) , , , .

3) " ".

. ... -, "-" , .

, memcpy():

MEMCPY(3)                  Linux Programmer Manual                 MEMCPY(3)

NAME
       memcpy - copy memory area

SYNOPSIS
       #include <string.h>

       void *memcpy(void *dest, const void *src, size_t n);

DESCRIPTION
       The  memcpy()  function  copies  n bytes from memory area src to memory
       area dest.  The memory areas must not overlap.  Use memmove(3)  if  the
       memory areas do overlap.

. memcpy() , . memcpy() , . , , . int, char .

+3

All Articles