Hi,
Anyone could elaborate the function of sizeof, calloc and free with the following examples:
#include <stdio.h>
struct date {
int hour, minute, second;
};
int x;
x = sizeof (struct date); //return a value?
struct date *date_pointer;
date_pointer = (struct date *) calloc(10, sizeof(struct date)); // What is this statement mean???
free (date_pointer); //When to use it?
Also, I want to know why "sizeof array / sizeof array[0]" can return the numbers of elements?
#include <stdio.h>
main()
{
int array[] = {5, 4, 3, 2, 1, 10, 8, 9, 89, 0, 1};
printf("The no. of elements in the array[] is %d\n", sizeof array / sizeof array[0]);
return 0;
}
BTW, is typedef equal to struct?
Thanks for any help.
gogo