Discussion
Which of the following are correct syntaxes to send an array as a parameter to function:
Answer: B
Correct answer: func(array);
An array name in an expression decays to a pointer to its first element, so passing the name is all that is required and the function receives that pointer. &array gives a pointer to the whole array, a different type; *array passes the first element rather than the array; and array[size] passes one element, and one that is out of bounds at that.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development