To further clarify things if you are still having some trouble. This is a simpler way of doing things by just using a pointer as an argument rather than a pointer to pointer:
Code:
#include <stdio.h>
void scan(int*,int*);
int main(int argc, char **argv)
{
int row, col;
scan(&row, &col);
printf("%d %d",row,col);
return 0;
}
void scan(int* a, int* b)
{
int c, d;
printf("Enter the size of matrix: ");
scanf("%d %d",&c, &d);
*a = c;
*b = d;
}
If you wanted to use a pointer-to-pointer as argument - which you don't need to in this case but heres how you would do it:
Code:
#include <stdio.h>
void scan(int**,int**);
int main(int argc, char **argv)
{
int* row, *col;
scan(&row, &col);
printf("%d %d",*row,*col);
return 0;
}
void scan(int** a, int** b)
{
int* c, *d;
printf("Enter the size of matrix: ");
scanf("%d %d",c, d);
*a = c;
*b = d;
}
You only really need a pointer-to-pointer argument if you wanted to modify the value of a pointer in another function. In this case you only wanted to modify the value of an integer in another function.