#Program to accessing through variable pointer
from ctypes import c_int
#Local definition
a = 22
a = c_int(a) # ctype datatype declaration
b = 2.25
b = c_float(b) # ctype datatype declaration
#Pointer variables
a_po=pointer(a)
b_po=pointer(b)
# 'id' is a address of letter and it represents the address of the variable
a = id(a)
b = id(b)
#Result
print "\nValue of a = %d" %a_po[0]
print "\nValue of b = %.2f" %b_po[0]
#Program to print address and value of variable
from ctypes import c_int
#Local definition
a = 22
a = c_int(a) # ctype datatype declaration
#Pointer variables
a_po=pointer(a)
# 'id' is a address of letter and it represents the address of the variable
a = id(a)
#Result
print "\n Value of a = %d" %a_po[0]
print "\n Address of a = %u" %id(a)
print "\n Value at address %u = %d" %(id(a),a_po[0])
# Program to print value and address of variable
from ctypes import c_int
#Local definition
a = 22
b = c_int(a) # ctype datatype declaration
#Pointer variable
b_po=pointer(b)
# 'id' is a address of letter and it represents the address of the variable
b = id(a)
#Result
print "\n Value of a = %d" %a
print "\n Value of a = %d" %(c_int(a).value)
print "\n Value of a = %d" %b_po[0]
print "\n Address of a = %u" %id(a)
print "\n Address of a = %u" %b
print "\n Address of a = %u" %id(b)
print "\n Value of b = address of a = %u" %b
#Program to illustrate pointer to pointer
from ctypes import c_int
#Local definition
a = 22
b = c_int(a) # ctype datatype declaration
c = c_int(a) # ctype datatype declaration
#Pointer variable
b_po = pointer(b)
c_po = pointer(b_po) # c_po is a pointer to another pointer
# 'id' is a address of letter and it represents the address of the variable
b = id(a)
c = id(b)
#Result
print "\n Value of a is %d" %a
print "\n Value of a is %d" %(c_int(a).value)