Тип void и указатель void *

Изменения в новых версиях / C89

// *** before: ***
//K&R C had no void: a function that returned nothing was still
//an int one, and a pointer to memory of any kind was a char *
printTotal(total)
int total;
{
    printf("total is %d\n", total);
}

int *squaresOld = (int *) malloc(3 * sizeof(int));   //malloc gave char *
squaresOld[2] = 4;
printTotal(squaresOld[2]);
free((char *) squaresOld);

// *** in version C89: ***
//void says "no value": nothing to return and nothing to ignore
void printSum(int sum) {
    printf("sum is %d\n", sum);
}

//void * points to anything: it turns into any object pointer
//and back without a cast
int *squares = malloc(3 * sizeof *squares);
squares[2] = 4;
printSum(squares[2]);
//sum is 4

free(squares);