How to Return an Array from a Function in C Part 2/2

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Hello, I am new in C and I am totally disagree with the previous comments, I was looking for a method to return higher order arrays (array of arrays) in my finite element code that I worked on, for few days I could not find a simple explination for how to do it, finally I have used these notices and it is working perfect. so many thanks to this clear explination.
Cheers

HAlBudairi
Автор

Excellent presentation, both videos were very informative.

jackmanjls
Автор

love the explanations but how can I use 5th solution when I want to return int array?

NagatoKamiPain
Автор

Very good. I have learned a lot form you.

mecrajib
Автор

Well I'm going through one doubt whether we need to dereference char pointer to print the string...actually we do such stuffs incase of integer pointers.

bipros
Автор

Great videos, thank you for the help!

fernandorodriguezjr
Автор

Isn't this pointless? Because arrays are passed by reference. I fyou throw in an array and modify it, you don't have to return it. ....or is there some other use for it that I am unaware of? Also i see this kinda hard because you would have to have a predefined array already built outside of the scope as a global array to hold the size non dynamically? am I missing your point in the point of it? What is the point of the way you did it?

SDTricker
Автор

Hello,
is this example is correct?

#include <iostream>
using namespace std;

int * Create(){
int T[10], i;
for ( i=0; i <10 ; i++){
T[i] = i;
}
return T;
}

int main(){
int *p;

// receive the address of the first element in the array T
p = Create();

//display all the other element is that array!
for (int i =0 ;i < 10 ;i++){
cout << *(p+i) << endl;
}

}

yosrimhamdi
Автор

Yes, it seems pointless. Maybe it would be useful if you would make a general function passing a void * and the type, but only modifying the contents of the array not returning it. Unless it was just an educational video, so ok but still some of the solutions i think they're really unnecessary,

thumbofel
Автор

doesn't work....I fucking hate c, its so long winded...

sidmicheals
Автор

I wonder if here is a use for this that I jsut don't see. I want to see the maker of this video's response. Pointless to me otherwise. hmmmm.

SDTricker