How do I declare a pointer to an array?

Answers were Sorted based on User's Feedback



How do I declare a pointer to an array?..

Answer / sureshreddy

data_type (*ptr)[];
ex: int (*ptr)[10];

pointer to arry of 10 elements

Is This Answer Correct ?    14 Yes 3 No

How do I declare a pointer to an array?..

Answer / shruti

you do not need to declare a pointer to any array..

an array itself is a constant pointer..

a[10] is equivalent to *a.

Is This Answer Correct ?    15 Yes 4 No

How do I declare a pointer to an array?..

Answer / chittaranjan

int (*ptr)[10];
is the proper declaration of pointer to an array, i.e. ptr
is a pointer to an array of 10 integers .

Note:
int *ptr[10];
which would make ptr the name of an array of 10 pointers to
type int.

Is This Answer Correct ?    9 Yes 0 No

How do I declare a pointer to an array?..

Answer / guest

int a[10];
int *ptr=a[0];

Is This Answer Correct ?    1 Yes 0 No

How do I declare a pointer to an array?..

Answer / guest

could any one help me out how this pointer to an array
organized in the memory?

Eg.,
int (*p) [3] = (int (*)[3])a;

Here *p == p, how?

Thanks in advance!

Is This Answer Correct ?    3 Yes 4 No

How do I declare a pointer to an array?..

Answer / k.thejonath

char (*)p[100];
Here p is a pointer to an array of 100 character elements..

Is This Answer Correct ?    6 Yes 11 No

Post New Answer

More C Interview Questions

In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

0 Answers  


Are pointers really faster than arrays?

0 Answers  


m=++i&&++j(||)k++ printf("%d"i,j,k,m)

1 Answers   ABC,


what is the use of macro program

1 Answers   TCS,


What are the disadvantages of external storage class?

0 Answers  






what value is returned to operating system after program execution?

0 Answers  


cavium networks written test pattern ..

0 Answers   Cavium Networks,


What are the types of functions in c?

0 Answers  


Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not

9 Answers   Alcatel,


Reverse the part of the number which is present from position i to j. Print the new number.[without using the array] eg: num=789876 i=2 j=5 778986

2 Answers  


Differentiate between ordinary variable and pointer in c.

0 Answers  


How can I find the modification date of a file?

0 Answers   Celstream,


Categories