Pass array to function in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pass array to function in c++

When we want to pass the array to a funtion using this syntax : void myFunction(int param[ ]) { . . . } Why does it pass the pointer not the array itself , cause we haven't use * before the array? Also can we pass the array to the function by value?

17th Mar 2020, 4:18 PM
Armina
Armina - avatar
5 Answers
+ 1
~ swim ~ Thanks for your explanation When we pass by reference ,is it reliable for the string?
17th Mar 2020, 5:05 PM
Armina
Armina - avatar
+ 1
~ swim ~ Thanks alot for your explanation
17th Mar 2020, 6:12 PM
Armina
Armina - avatar
0
~ swim ~ So it's just by the design of the memory that the array pass by pointer? Why it just pass the first element of the array by a pointer , what about the rest of the array?
17th Mar 2020, 4:42 PM
Armina
Armina - avatar
0
~ swim ~ In dimensional array when we want to pass the using this syntax: void myFunction(int param[]) { . . . } It points to the first element of the first array ,so how it points the elements of the next array?
17th Mar 2020, 5:31 PM
Armina
Armina - avatar
0
~ swim ~ When we pass the size , is it ok it dynamic array too? ( i mean the complier doesn't know the number of elements till the run time)
17th Mar 2020, 6:00 PM
Armina
Armina - avatar