Define the following variables given by a

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

a)An integer(An integer)

b) A pointer to an integer(A pointer to an integer)  

c) A pointer to a pointer, a pointer to a pointer to an integer(A pointer to a pointer to an integer)

d) A 10 integer array(An array of 10 integers)

e) A 10 pointers, the pointer to an integer(An array of 10 pointers to integers)

f) A pointer to a pointer to integer count group 10(A pointer to an array of 10 integers)

g) A pointer to a function, the function that takes an integer as an argument and returns an integer(A pointer to a function that takes an integer as an argument and returns an integer)

h) A 10 function pointers, the pointer to a function, the function that takes an integer as an argument and returns an integer( An array of ten pointers to functions that take an integer argument and return an integer )

Answer:

a) int a; // An integer

b) int *a; // A pointer to an integer

c) int **a; // A pointer to a pointer to an integer

d) int a[10]; // An array of 10 integers

e) int *a[10]; // An array of 10 pointers to integers  (int * modified behind the array)

f) int (*a)[10]; // A pointer to an array of 10 integers

g) int (*a)(int);// A pointer to a function a that takes an integer argument and returns an integer

h) int (*a[10])(int); // An array of 10 pointers to functions that take an integer argument and return an integer


The definition of a pointer to a XXX, the XXX is defined, then (*a) XXX to replace the variable name

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Avivi at November 18, 2013 - 8:52 AM