anonymous
  • anonymous
can any1 help me regarding "passing multidimensional arrays"?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
i have a dynamic array and i have to fill it with random values............. so i have to do smthin like randomAssign(&array,size) void randomAssign(int ***array,int size) { int i,j; for(i=1...size) for(j=1...size) array[i][j]=rand(); return; } but this gives a segmentation fault? so wer did i go wrong?
anonymous
  • anonymous
@nick67 @slotema
anonymous
  • anonymous
array is of type int ** int **array; array = builder(size); and my builder function is here int ** builder(int n) { int i; int *array=malloc(n*sizeof(int)); for(i=0;i

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
@ktobah
anonymous
  • anonymous
You know when you want to pass an Array as argument, don't use &, because C/C++ consider arrays as addresses. Try this .
anonymous
  • anonymous
nope tried that.............it dint work
anonymous
  • anonymous
any ideas?
anonymous
  • anonymous
I really don't have any idea, sorry.
anonymous
  • anonymous
tsk thanks nyway.......
anonymous
  • anonymous
You're welcome.
nick67
  • nick67
@A.Avinash_Goutham try something like this (with this example you have a 10x10 array with random values up to 99: #include #include #include using namespace std; #define ARRAY_SIZE 10 void randomAssign(int *array_ptr,int size) { int i,j; srand ( time(NULL) ); for(i=0;i
anonymous
  • anonymous
Sir, the array should be dynamic...........i shud be able to give the size at the run time.....
anonymous
  • anonymous
main() { int n,i,j; printf("enter the size of the maze:"); scanf("%d",&n); static int **array; array=builder(n); if(array) { printf("array creation succesfull\n"); } printf("%d\n",rand()); assign(array,n); randomAssign(array,n); print(array,n); } int ** builder(int n) { int i; int *array=malloc(n*sizeof(int)); for(i=0;i
anonymous
  • anonymous
that was my code..

Looking for something else?

Not the answer you are looking for? Search for more explanations.