There is a slight twist to the pointer-to-pointer answer...
When you have an array of a given type and you pass it to a function, what is passed to the function is actually a pointer to the first element. So an int array (of any size) turns up at the function as an int* to the first element. This is known as array decay.
#include <iostream>
#include <string>
usingnamespace std;
constint MAX = 3;
// C++ also allows you to use [] instead. But if you uncomment this
// "overload" of test you'll find that the compiler thinks it's the same
// as the following one so hitting the one definition rule.
//
// (In fact, you can put a number in the [] -- BUT IT'S IGNORED!)
//
//void test(int arr[])
//{
// for (int index = 0; index < MAX; ++index)
// cout << "arr[" << index << "] = " << arr[index] << "\n";
//}
void test(int* arr)
{
for (int index = 0; index < MAX; ++index)
cout << "arr[" << index << "] = " << arr[index] << "\n";
}
int main ()
{
int arr[MAX] = {1, 2, 3};
test(arr);
return 0;
}
As your array is an array of char*s, what turns up at the function is a pointer to a char*, otherwise known as a char**.
ah i get it now thanks you guys and yea sorry about that andywestken just our professor are giving us examples of stuff like this and we have to look at them and figure whats going on