Problem With Void

#include <iostream>
using namespace std;
void g();
int main() {
void g();
system ("PAUSE");
return 0;
}
void g(){
cout <<"hi there";
}
I'm just playing around trying to get the hang of void, but when I run it it doesn't output hi there. What am I doing wrong?
You need to call the function, like this:
g();

This line of code:
void g();
means "there exists a function called g that takes in no parameters and returns none. It does not call the function, just states that the function exists.

While I'm here, this
system ("PAUSE");
is a terrible habit to get into.
First of all, welcome to the forum. When posting code, please use [c0de][/c0de] tags (replaces 0's with o's).

Your problem is here:

1
2
int main() {
void g();


remove the word void from inside the main when calling the function and it will work fine.
Thank you guys! I know system stuff is bad I am just playing around.
I'm not sure I understand how to post coding.
Thanks firedraco!!!
Thank You!!
Topic archived. No new replies allowed.