Turbo C - Pointer Declaration
Pointers are used to point to a memory location. In Turbo C, size of pointer variable in 2 bytes since it is a 16 bit applications where as in visual c++ it would be 4 bytes since it 32 bit applilcation. Today 64 bit compilers will allocate 8 bytes for a pointer variable.
The following is a good example illustrating the concept of pointer.
Source Code
#include <stdio.h>
void main()
{
int n = 100;
int *p1 = &n;
int *p2 = NULL;
printf("Pointer %u contains %d\n", p1, *p1);
*p1 = 200;
p2 = &n;
printf("Pointer %u contains %d\n", p2, *p2);
printf("N = %d\n",n);
return;
}
Output
Pointer 12442 contains 100
Pointer 12442 contains 200
N = 200
|