Void function problem.

Hello!

I am new to c++ and I am trying to leran how to work with functions.
In my textbook there is an assignment to take an earlier program and use it as a function.
I am supposed to later make a menu that calls old assignments I have made, so I guess I have to make them into functions.

When I use this code the screen is just blank.

Is it wrong to use void, maybe?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;

void weather()
{
	char choice;

	do
	{
		cout << "Is the weather nice?" << endl << "y/n:" << endl;
		cin >> choice;

		if (choice != 'y' || choice != 'Y' || choice != 'N' || choice != 'n')
			cout << "I dont understand" << endl << "try again" << endl;

	}while (choice != 'y' || choice != 'Y' || choice != 'N' || choice != 'n');


	if (choice == 'y' || choice == 'Y')
	{
		cout << "Lets go to picknick.";
	}

	else if (choice == 'n' || choice == 'N')
	{

		cout << "Lets stay in.";
	}
}

int main()
{
	void weather();

	cin.get();
	cin.get();
	return 0;
}
When you call the function you should not write void.

 
void weather();
Last edited on
void weather(); // That's not how you call a function, remove void.

http://www.cplusplus.com/doc/tutorial/functions/
I am kicking myself right now. I am sorry for taking your time with this.

Thank you!

Topic archived. No new replies allowed.