+ 1

In c why we don't have to return an array

If we have some values in an array inside main() function and we pass it to other function and change all that values how come we see the changed value in our main function :/ i know the answer but just want to know your views about it.

1st Sep 2017, 6:15 AM
Mohit Rawat
Mohit Rawat - avatar
2 odpowiedzi
+ 13
C is all about memory pointers and arrays are treated as such when you pass an array to a function you are actually passing its starting address so the same way that passing a variable by pointer to another function and modifiyng it inside that function will be reflected in the function that passed the pointer you are simply passing by address rather than value
1st Sep 2017, 6:22 AM
Burey
Burey - avatar
+ 1
WOOH
1st Sep 2017, 2:24 PM
Mohit Rawat
Mohit Rawat - avatar