
Patrick B. answered 05/20/19
Math and computer tutor/teacher
You are correct: & is the address operator which gives the address of the variable;
* is the dereference operator which gives the value of the variable, pointed
to by the pointer
==================================================================
You can pass the address of the variable to a function. In fact, you do just that when using scanf...
int qty;
float price;
printf(" Please input the price of the item :>");
scanf(" %f ", &y);
printf(" Please input the quantity : how many ??? :>");
scanf(" %d", &qty);
float subtotal = qty * price;
=======================================================
The NAME of the array variable IS, in and of itself, the BASE ADDRESS, or
address of the first element in the array.
So you can pass an array just by passing it's name.
Ex. void printArray ( int count, int * A)
{
for (int iLoop=0; iLoop<count; iLoop++)
{
printf("%d ",A[iLoop]);
}
printf("************\n");
}
then in main()..........
int A[10] = {1,2,3,4,5,6,7,8,9,10};
printArray(10,A);
notice that the function takes as it's argument, an integer containing the # of elements in the array,
and then a pointer to integer which receives the base address of the array
=================================================================
Please come back with more specific questions. I am available for tutoring