i have problem passing double pointer to my funciton
first i declare: int m, n;
i read m and n from user just fine (i've checked that)
then i declere: int farm[m][n];
and i have a function... void harvest(int **farm,...);
and when i call it with: harvest (farm,...);
it says (compiler says):
cannot convert 'int (*)[((unsigned int)((int)n))]' to 'int**' for argument '1' to 'void harvest(int **,...)'
Alibeg
1
Junior Poster in Training
Recommended Answers
Jump to PostA two dimensional array is not the same type as a pointer to a pointer. If you want to pass a two dimensional array, change your function to accept the correct type. If you want to pass a pointer to a pointer then pass the correct type.
So what …
Jump to PostWhen you pass an array to a function you don't need to put in the [] brackets, unless your sending a multidimensional array (2D array) as your trying.
You should prototype your function like
void harvest(int farm[m][n]...)
and call it in your program like thisharvest(farm...);
Jump to Post>i am new to this so i guess i am making stupid mistake
It doesn't seem that way. If you were using a C99 compiler, it would work due to the new variable length array feature. However, unless you're able to compile as C99 (the latest standard) or your compiler …
Jump to Post>im using minGW GCC that comes with newest version of CodeBlocks
You have to turn C99 mode on with a switch: -std=c99.>correct me if im wrong but you said that i need to use:
Did you completely ignore everything I said? Also, by the looks of your code …
All 15 Replies
Narue
5,707
Bad Cop
Team Colleague
Alibeg
1
Junior Poster in Training
kenji
1
Junior Poster
Alibeg
1
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Alibeg
1
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Alibeg
1
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Alibeg
1
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Alibeg
1
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Alibeg
1
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.