[try Beta version]
Not logged in

 
Problem!!! Help!!

May 22, 2019 at 8:29pm
Hi guys! I have a problem that i hope you give me an advice to solve it. I have writing this code and it doesn't run cuz its a problem.

C2562 'Draw':'void' function returning a vaue.....


I dont know what to correct.




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
39
40
41
42
43
44
45
#include <iostream>
using namespace std;

bool gameOver;
const int width = 20;
const int height = 20;

int x, y, fruitX, fruitY, score;
enum eDirection {STOP = 0, LEFT, RIGHT, UP, DOWN};
eDirection dir;

void Setup()
{
	gameOver = false;
	dir = STOP;
	x = width / 2;
	y = height / 2;
	fruitX = rand() % width;
	fruitY = rand() % height;
	score = 0;
	
}
void Draw()
{
	system("cls"); // system clear;
	for (int i = 0; i < width; ++i)
		cout << "#";
	cout << endl;

	for (int i = 0; i < height; ++i)
	{
		for (int j = 0; j < width; j++)
		{
			if (j == 0)
				cout << "#";
			cout << "";
			if (j == width - 1)
				cout << "#";

		}
		cout << endl;
	}
	

}


thank u!
Last edited on May 23, 2019 at 7:04am
May 22, 2019 at 8:39pm
I see no such error in your code.
Are you sure you posted the code producing the error?

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
May 23, 2019 at 7:05am
This is the problem: "C2562 'Draw':'void' function returning a vaue"
May 23, 2019 at 7:59am
slim wrote:
I dont know what to correct.

The code you provided doesn't cause the error you claim. So you have muddled your files somehow.

Here is your function Draw(). It does not contain the word "return" anywhere.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void Draw()
{
	system("cls"); // system clear;
	for (int i = 0; i < width; ++i)
		cout << "#";
	cout << endl;

	for (int i = 0; i < height; ++i)
	{
		for (int j = 0; j < width; j++)
		{
			if (j == 0)
				cout << "#";
			cout << "";
			if (j == width - 1)
				cout << "#";
		}
		cout << endl;
	}
}
Last edited on May 23, 2019 at 8:23am
May 23, 2019 at 1:49pm
Show a complete example that reproduces your issue, else you're just wasting time.

And actually copy the error message(s). You clearly didn't do this, because you misspelled 'value' both times.
Last edited on May 23, 2019 at 1:49pm
Topic archived. No new replies allowed.