Well. The first thing you must have understood is the way that C implements the arrays. Basically in C a pointer and an array is the same thing. A pointer is a 4bytes (or 2 sometimes) integer variable. The value of the pointer represents a memory address. You declare a pointer to char this way:
char* pname;
You take a char's address using the & operator.
eg char c;
pname = &c; // pname holds c's address.
You have access at the memory position a pointer "points" using the * operator.
eg *pname = 'f' // the char that is at the position pname points, changes to 'f'
An array is tha same thing. It is a pointer to a memory address. The difference here is that you have more than one pointed items.
eg. char ar[10];
ar is of type char*. The system allocates memory space to hold 10 chars. The memory positions of that chars are sequential. if the first is at the memory position 1000 the second is at 1001 and so on until the tenth which is at 1009.
The variable ar is a pointer that holds the memory address of the first of those 10 chars.
The expression (ar) is the same with (&ar[0]). ar is a pointer to the first char, thus it's value is the address of the array's first element.
(ar[0]) is the same with (*ar). ar[0] is the first char and *ar is the char that ar points to (and ar points to the first char). (ar[1]) is the same with (*(ar + 1)). ar[1] is the second char of the array, and *(ar + 1) is the char that ar points to if you add it with 1. (1000 + 1 = 1001 which is the address of the second char if the first's char address is 1000).
So. Arrays ARE Pointers. But pointers ARE variables too and they ARE stored in memory so they HAVE addresses too. The address of ar can be taken like this : &ar. This value is a pointer that holds the address of ar. ar is a pointer that holds the address of a char. So ar's address is of type char** (pointer to a pointer to char). This is recursive. You can have pointers to pointers to pointers to something and so on.
So. As you can have arrays of (pointers to) ints, you can also have arrays of (pointers to) pointers too. Eg.
char* String[10];
String is an array of 10 pointers to char. This means String[0],String[1],... are pointers to chars. BUT ar was an array of chars which means that ar was a pointer to char. Yes. And Each element of String is a pointer to char. Yes. That means that each element of String is an array too. YES. So String is an array of arrays. YES.
String is an array of pointers. But arrays and pointers is the same concept. So String is an array of arrays. String[0] is an array of chars. String[1] is an array of chars too. This is the two-dimensional array. And this is the way C implements the multi-dimensional arrays. A 2d array is an 1d array of 1d arrays.
A 3d array is an 1d array of 2d arrays.
and so on.
String is a pointer to char* (because each element is a pointer to char) so String is a char**.
In your example
char salesMan[10][25]
salesMan is a char**. (array of arrays of chars)
salesMan[0] is a char*. (array of chars)
salesMan[0][0] is a char;
don't forget. in C Arrays ARE pointers. The array name is a pointer that points to the first element of the array.
salesMan points to salesMan[0], which is char*.
SalesMan[6] points to salesMan[6][0] which is char. // The first char of the 7th array of salesMan
So if you want to pass salesMan as an array to a function you must pass a char**.
eg
void myfunc(char** salesArray);
In the function body you can use salesArray as a normal 2d array using [][].
eg char c = salesArray[6][4];
or
char d[20]; // an array of chars
strcpy(d,salesArray[5]); // this copies the 6th string of salesArray to array d.
if the dimensions are not known to the function you can pass them as arguments too.
eg
void myfunc(char** array,int rows,int cols);
eg
char names[60][20] // This holds 60 names of at most 20 characters each.
myfunc(names,60,20); // myfunc takes a char** as argument and names IS a char** because it is an array of char*, or else an array of arrays of chars, or else a pointer to pointers to chars, thus a char**. :)
----------------
Your code is syntactically correct.
inputSalesmanData takes as an argument a char*
You call this function in this line
inputSalesmanData(*salesMan, salesFigure);
salesMan is a char** so *salesMan is a char*. (That is what the function takes as an argument)
This is exactly the same with this call
inputSalesmanData(salesMan[0], salesFigure);
Because salesMan points to the first char* in the array which is salesMan[0].
You pass an array in the function but not the whole 2d array. Only its first row, salesMan[0].
If you want to pass the whole 2d array you must declare the function like that
void inputSalesmanData(char **salesMan, float *salesFigure);
and call it like this
inputSalesmanData(salesMan,salesFigure); // again salesMan IS char** (2d array)
(I believe salesFigure is a float* and you have a reason to pass this pointer here. If you just want to pass a float and don't want to change it inside the function's body, there is no need of a pointer here. just pass a float, not a float*)
Believe me i was confused while i was writing this, but i hope some things about pointers and arrays are more clear now. :( (Are they??) :)
S.A.Y.S. Sam. (Sam At Your Service)
(Sorry for my english. I'm Greek and never tried to explain something in a language other than mine. :) )