In the C programming language variables are declared before the program itself starts, before functionality. This applies to functions also.
With an example:

     int iCnt = 0;
     int iValue = myFunc();
}//end main
int myFunc(){
     return 1;
}//end myFunc

The following program declares c primitive data types and pointer data types and does print the size for them too.

// variableSizes.c
// This is a simple c to write out variable sizes

#include <stdio.h>
#include <stdlib.h>


	char chTest = 'c';
	char chPrt = &chTest;

	short shTest = 1;
	short shPtr = &shTest;

	int iTest = 1;
	int iPtr = &iTest;

	long lTest = 1l;
	long lPtr = &lTest;

	long long llTest = 1l;
	long long llPtr = &llTest;

	float fTest = 0.1;
	float fPtr = fTest;

	double dTest = 0.1;
	double dPtr = dTest;

	long double ldTest = 0.1l;
	long double ldPtr = ldTest;

	puts("C language data sizes\n==============================\n");
	printf("char in bytes: %d\n", sizeof(char));
	printf("short in bytes: %d\n", sizeof(short));
	printf("short int in bytes: %d\n", sizeof(short int));
	printf("int in bytes: %d\n", sizeof(int));
	printf("long in bytes: %d\n", sizeof(long));
	printf("long long in bytes: %d\n", sizeof(long long));
	printf("float in bytes: %d\n", sizeof(float));
	printf("double in bytes: %d\n", sizeof(double));
	printf("long Double in bytes: %d\n", sizeof(long double));

	puts("C language data sizes\n==============================\n");
	printf("char in bytes: %d\n", sizeof(&chPrt));
	printf("short in bytes: %d\n", sizeof(&shPtr));
	printf("int in bytes: %d\n", sizeof(&iPtr));
	printf("long in bytes: %d\n", sizeof(&lPtr));
	printf("long long in bytes: %d\n", sizeof(&llPtr));
	printf("float in bytes: %d\n", sizeof(fPtr));
	printf("double in bytes: %d\n", sizeof(dPtr));
	printf("long Double in bytes: %d\n", sizeof(ldPtr));


}//end main()
Share This