How can you pass an array to a function by value?



How can you pass an array to a function by value?..

Answer / Bushra Saher

In C, arrays decay into pointers when passed as arguments, so passing an array to a function is effectively passing its address. To pass an entire array by value, use a pointer to the first element of the array.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }

4 Answers  


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1 Answers  


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1 Answers  


Is anything faster than c?

1 Answers  


What is the purpose of the statement: strcat (S2, S1)?

1 Answers  


Compare interpreters and compilers.

1 Answers  


what is the full form of c language

9 Answers   Satyam, TCS, VNC,


wite a programme in c to linear search a data using flag and without using flags?

3 Answers   TCS,


What are the applications of c language?

1 Answers  


What are keywords c?

1 Answers  


what are bps & baud rates? differentiate these two?

2 Answers   TCS,


What is the general form of function in c?

1 Answers  


Categories