+ 12

how to return an array in c .

unfortunately im having a problem that i need to write a function in C that returns an array but i did'nt study pointers yet , so my question is , is it possible to return an array value without using pointers ?

30th Jun 2018, 1:17 PM
Anon Fox
Anon Fox - avatar
8 ответов
+ 4
C programming does not allow to return an entire array as an argument to a function. However, you can return a pointer to an array by specifying the array's name without an index.
30th Jun 2018, 1:28 PM
Frank Abagnale
Frank Abagnale - avatar
+ 6
Baptiste E. Prunier haha ! Thank you , ill keep this code saved for the next year , coz we did'nt quiet get into data structures in the first year . But i appreciate your answer ^^ .
30th Jun 2018, 8:27 PM
Anon Fox
Anon Fox - avatar
+ 6
Baptiste E. Prunier Yep it surely is :).
30th Jun 2018, 9:31 PM
Anon Fox
Anon Fox - avatar
+ 5
You can return array like that, even though it is quiet ... unusual ^^ https://code.sololearn.com/cvvS26r7f118/?ref=app
30th Jun 2018, 7:00 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 5
TA .A you are welcomed :) Hope it'll be of some help !
30th Jun 2018, 8:47 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
Frank Abagnale oh got it , so then i can loop over this array by the pointer i returned right ?
30th Jun 2018, 1:29 PM
Anon Fox
Anon Fox - avatar
+ 3
Frank Abagnale Thanks man !
30th Jun 2018, 1:38 PM
Anon Fox
Anon Fox - avatar
0
Sure, you can loop over the array.
30th Jun 2018, 1:36 PM
Frank Abagnale
Frank Abagnale - avatar