Reputation:
I'm using GCC Compiler 9.3.0 on GNU/Linux Environmental, using C17.
If I remove largest_lowest call from main function there is not seg fault if I add that line there is a seg fault (core dumped)
SetData is a simple function just to set data only. Nothing more and works perfectly.
Error(When compiling)-> expected ‘point **’ but argument is of type ‘point (*)[7]’
And when I run the program there is a seg fault (core dumped).
Upvotes: 0
Views: 137
Reputation: 213882
You cannot pass a multi-dimensional array to a function taking pointer-to-pointer. Particularly since in this case, you are intend to pass a single dimension array. Fixes:
int largest_lowest(point *a[], int len)
- > point a[]
, and
largest_lowest(&a, 7);
-> largest_lowest(a, 7);
Also, please note that the function-like macro INIT_POINT_ARRAY
is horrible practice and you must get rid of it. There is absolutely no reason why you should have a macro there.
Upvotes: 1