Skip to main content
Post Undeleted by anastaciu
added 93 characters in body
Source Link
anastaciu
  • 24.1k
  • 7
  • 37
  • 62

I reckon that Allan Wind already provides a nice a clean (as much as it can be) solution, but, if you like to live onI would add that the edge thenrequirement of using a pointer to pointer parameter to take a 1D array argument makes little sense when you can try thisuse a simple pointer. Look how much more simple it looks:

#include <stdio.h> void double_function(double **arr*arr) { printf("Value at 1: %f \n", arr[1]); } int main() { double arr[3] = {0.11, 1.2, 2.56}; double_function((double**)&arrarr); } 

Now this is bit of a hack, but it avoids the use of another pointer.

I reckon that Allan Wind already provides a nice solution, but, if you like to live on the edge then you can try this:

#include <stdio.h> void double_function(double **arr) { printf("Value at 1: %f \n", arr[1]); } int main() { double arr[3] = {0.11, 1.2, 2.56}; double_function((double**)&arr); } 

Now this is bit of a hack, but it avoids the use of another pointer.

Allan Wind already provides a nice a clean (as much as it can be) solution, I would add that the requirement of using a pointer to pointer parameter to take a 1D array argument makes little sense when you can use a simple pointer. Look how much more simple it looks:

#include <stdio.h> void double_function(double *arr) { printf("Value at 1: %f \n", arr[1]); } int main() { double arr[3] = {0.11, 1.2, 2.56}; double_function(arr); } 
Post Deleted by anastaciu
Source Link
anastaciu
  • 24.1k
  • 7
  • 37
  • 62

I reckon that Allan Wind already provides a nice solution, but, if you like to live on the edge then you can try this:

#include <stdio.h> void double_function(double **arr) { printf("Value at 1: %f \n", arr[1]); } int main() { double arr[3] = {0.11, 1.2, 2.56}; double_function((double**)&arr); } 

Now this is bit of a hack, but it avoids the use of another pointer.