1. ## please can some1 see whats wrong with this (newbie)

hi all. im new to c++, trying to teach myself from internet tutorials... its slow progress. anyway i wanted to make a program to solve a puzzle. i havent even got on to writing an algorithm for working it out yet. im stuck trying to make a function that prints a 9x9 2 dimentional array. heres the complete program

Code:
```#include <iostream>

using namespace std;

void print_table(int array);

int main()
{
int table[9][9];
for(int i=0;i<9;i++)
{
for(int ii=0;ii<9;ii++)
{
table[i][ii] = 0;
}
}
int *ptr;
ptr = table;
print_table(ptr);
cin.get();
}

void print_table(int array)
{
for(int i=0;i<9;i++)
{
for(int ii=0;ii<9;ii++)
{
cout << *array[i][ii] << "|";
}
cout << "- - - - - - - - -" << endl;
}
}```

18 C:\Dev-Cpp\Untitled1.cpp cannot convert `int[9][9]' to `int*' in assignment

so im assuming it has something to do with the fact that i dont know how to pass an array to a function, im just guessing. thanks in advance for help. first post here

2. Lose the * in front of array in your cout statement and change void print_table(int array) to void print_table(int *array).

3. Or even better
Code:
```#include <iostream>

using namespace std;

void print_table(int array[9][9]);

int main()
{
int table[9][9];
for(int i=0;i<9;i++)
{
for(int ii=0;ii<9;ii++)
{
table[i][ii] = 0;
}
}
print_table(table);
cin.get();
}

void print_table(int array[9][9])
{
for(int i=0;i<9;i++)
{
for(int ii=0;ii<9;ii++)
{
cout << *array[i][ii] << "|";
}
cout << "- - - - - - - - -" << endl;
}
}```

4. ok thx

5. main() should return an int sir....I don't see a return statement.

6. According the gurus and those with access to a copy of the current standard, you no longer need to explicitly return an int from main(), though many of us still do, out of habit if nothing else.

7. When did this standard modification come out?
Last time I tried to use plain main with no return type I got yelled at and pointed to some articles lol...

8. The thing people yell about is that the declaration of main should specify a return type of int, not void. If control reaches the end of main and nothing is returned, then 0 will be returned automatically. This is special to the main function.

That rule has always been in the standard.

Old compilers, especially VC++ 6.0 don't follow the standard in this case and will give warnings and do the wrong thing if you don't return something with an int return type specified.

9. > Last time I tried to use plain main with no return type I got yelled at and pointed to some articles
New-style C++ (those with namespaces) allow a returnless main to be implicitly return 0;
Old C++ and anything C needs an explicit return 0; at the end.

Personally, I think it's just a sop to all the void main programmers to make it easy for them to update their code by just changing one word.

10. Originally Posted by Salem
Personally, I think it's just a sop to all the void main programmers to make it easy for them to update their code by just changing one word.
This story never ends. I think the C standard should enforce correct use of main. Compilers should just give an error when main is used wrongly.

11. They do. Try to compile void main on the latest GCC or G++ and see what happens.
Code:
```#include <iostream>

void main()
{
std::cout<<"Hello"<<std::endl;
std::cin.get();
}```
gcc version 3.4.2 (mingw-special)
4 C:\Dev-Cpp\boardCode\void.cpp `main' must return `int'
4 C:\Dev-Cpp\boardCode\void.cpp return type for `main' changed to `int'