functions anywhere? (in the module)
Firstly, Hi to the board!
Can anyone tell me what is wrong with this code? I have read that "A function can be defined anywhere in the module".
Although when I define the same function before the main function, it works when I call it.
Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs,
char* pszArgs[])
{
void hello()
{
cout << "hello" << endl;
}
hello();
system("PAUSE");
return 0;
}
When I try to compile and execute I get the message...
Line 9: expected primary-expression before "void".
This works fine...
Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
void hello(void)
{
cout << "hello" << endl;
}
int main(int nNumberofArgs,
char* pszArgs[])
{
hello();
system("PAUSE");
return 0;
}
Any help would be greatly appreciated. Thanks!