|
void table_print(int array, int size)
|
Your 'array' value here is of type
int
. IE: it's a single integer, not a pointer.
You probably meant to do this:
|
void table_print(int* array, int size)
|
Note the * here makes it a pointer.
Your table_fill function has the same problem.
Also you have a problem here:
1 2 3 4
|
for (int i = 0; i < size; i++)
{
cout << *array << " " << endl; // <- you're only printing the 1st element in the array
}
|
By printing
*array
repeatedly, you will just print the first element in the array over and over again. This is not what you wanted to do. Instead, you want to iterate through the array. This can be done 2 ways:
1) increment the pointer after every print.
1 2
|
cout << *array << " " << endl;
++array;
|
or
2) Use the subscript [bracket] operator to index the array.
|
cout << array[i] << " " << endl;
|
Personally I find #2 to be much simpler and more clear.