Hi,
I'm just learning about pointers and as a simple exercise I am trying to print the elements of the array. I'm trying to write a simple function that cycles through the columns and then prints each value to the screen. However, I'm having trouble calling the function properly.
Code:
/*Function the prints a single row array's contents to the screen. */
void matrix_print(int row, int col, double *m){
int i;
for(i=0; i<col; i++){
printf("%d ",*(m+i*col));
}
printf("\n");
}
main(){
double arr[5] = { 2.5, 3.2, 18.7, -1.35, 4.2 };
matrix_print(1, 5, *arr[5]); //causing an error
}
The problem in the 3rd argument to the of the matrix_print. The error says that it is an compatible type. Any suggestions?
Thanks in advance!