no compilation error but still not running

hello

I've make a project and its work fine with my friend computer

but om my computer i use dev c++ ,, the code did not show compilation errors

but i cant run it!! when i click run its do nothing !! i dont know where the problem is

here is the main

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "Map.h"
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <random>
#include <string.h>
using namespace std;
struct point{
	int x, y;
	point(){};
	point(int a, int b){
		x = a;
		y = b;
	}
};
void FloodFill(point*, point*);
int floodFill(point*, point*);

char **path;
int dim;

int main(){
	cout << "Enter map grid size: (eg 10) ";
	cin >> dim;

	Map testmap = Map(dim);
	Graphics::fullscreen();
	point *start = new point(), *end = new point(), *current = new point();

	while (true){
		cout << "Set start point x and y: ";
		cin >> start->x >> start->y;
		if (testmap.getMap()[start->x][start->y] == -1)
			cout << "This location has an obstacle, enter different values" << endl;
		else
			break;
	}
	while (true){
		cout << "Set end point x and y: ";
		cin >> end->x >> end->y;
		if (testmap.getMap()[end->x][end->y] == -1)
			cout << "This location has an obstacle, enter different values" << endl;
		else
			break;
	}
	start->x = 0, start->y = 5;
	end->x = 5, end->y = 0;
	system("cls");


	testmap.setInit(start->x,start->y);
	testmap.setFinal(end->x,end->y);
	testmap.drawMap();
	path = new char*[dim];
	for (int i = 0; i < dim; i++){
		path[i] = new char[dim];
		for (int j = 0; j < dim; j++)
			path[i][j] = testmap.getMap()[i][j];
	}

	FloodFill(start,end);
	//set current location to be start location
	current->x = start->x;
	current->y = start->y;
	int currentValue = path[current->x][current->y];
	while (true){
		Sleep(100);
		testmap.setRobotLocation(current->x, current->y);
		currentValue--;
		//update location until we reach end
		if (current->x-1 >= 0)
		if (path[current->x-1][current->y] == currentValue){
			current->x--;
			testmap.setRobotLocation(current->x, current->y);
		}
		if (current->x + 1 < dim)
		if (path[current->x + 1][current->y] == currentValue){
			current->x++;
			testmap.setRobotLocation(current->x, current->y);
		}
		if (current->y - 1 >= 0)
		if (path[current->x][current->y - 1] == currentValue){
			current->y--;
			testmap.setRobotLocation(current->x, current->y);
		}
		if (current->y + 1 < dim)
		if (path[current->x][current->y + 1] == currentValue){
			current->y++;
			testmap.setRobotLocation(current->x, current->y);
		}
		if (currentValue == 1)
			break;
	}
	cout << "Success" << endl;
	_getch();
}

void FloodFill(point *current, point *dest){
	path[current->x][current->y] = -2;
	path[current->x][current->y] = floodFill(current, dest);

}

int floodFill(point *current,point *dest){	
	//starts from target node with level 0
	if (current->x == dest->x && current->y == dest->y){	//mean we reached at destination
		path[current->x][current->y] = 1;
		return 1;
	}
	int ret;
	//if not at destination then recursively call to any available path that is not previsous path
	if (current->x + 1 < dim && path[current->x + 1][current->y] != -1 && path[current->x + 1][current->y] != -2 && path[current->x + 1][current->y] <= 0){
		path[current->x][current->y] = -2;
		current->x++;
		ret = floodFill(current,dest);		//go right
		current->x--;
		if (ret != -1){
			path[current->x][current->y] = ret + 1;
			return ret + 1;
		}
	}
	if (current->x - 1 >= 0 && path[current->x - 1][current->y] != -1 && path[current->x - 1][current->y] != -2 && path[current->x - 1][current->y] <= 0){
		path[current->x][current->y] = -2;
		current->x--;
		ret = floodFill(current, dest);	//go left
		current->x++;
		if (ret != -1){
			path[current->x][current->y] = ret + 1;
			return ret + 1;
		}
	}
	if (current->y + 1 < dim && path[current->x][current->y + 1] != -1 && path[current->x][current->y + 1] != -2 && path[current->x][current->y + 1 ] <= 0){
		path[current->x][current->y] = -2;
		current->y++;
		ret = floodFill(current, dest);	//go down
		current->y--;
		if (ret != -1){
			path[current->x][current->y] = ret + 1;
			return ret + 1;
		}
	}
	if (current->y - 1 < dim && path[current->x][current->y - 1] != -1 && path[current->x][current->y - 1] != -2 && path[current->x][current->y - 1] <= 0){
		path[current->x][current->y] = -2;
		current->y--;
		ret = floodFill(current, dest);	//go up
		current->y++;
		if (ret != -1){
			path[current->x][current->y] = ret + 1;
			return ret + 1;
		}
	}
	return -1;
	return 0;

}
Last edited on
pleasssssssssssssssssssse any help :(
That doesn't compile on any compiler made since about 1998, and it also won't compile on any compiler I can think of from before 1998. It's a horrible mish-mash of code. What are you compiling it with? What's providing you with the non-standard conio.h ? What's Graphics::fullscreen(); ? Where's that coming from? Is this some kind of allegro library based thing?

You're using a lot of non-standard code here, and without knowing what you're using it's going to be very hard to help you.

Note that "dev CPP" is not a compiler. It's an IDE. It probably comes with a compiler. What compiler did it come with?

I'd seriously recommend you get a compiler made in the last fifteen years. Maybe even made in the last year.
Last edited on
thank you Moschops (6057) for your replay

Graphics::fullscreen() come from map.h and map.h include Graphics.h

this is all the header files :-

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
#pragma once
class Graphics
{
public:

	static void go(int, int);					//set cursor to a location
	static void fontsize(int, int);				//set font sizes to pre defined ratio
	static void fullscreen();					//increase the console window size to maximum
	static void rgb(int, int, int, int);		//change the value of existing simple graphic color
	static void square(int, int, int, int);		//draw simple square
	static void Hsquare(int, int, int, int);	//draw hollow square
	static void fsquare(int, int, int, int);	//draw square with nice frame
	static void clr(int);

	static void drawCircle(int center_x, int center_y, int radius);					//simple circle
	static void drawCircle(int center_x, int center_y, int radius, int thickness);	//circle with boundry thickness
	static void drawFillCircle(int center_x, int center_y, int radius);				//simple fill circle

	static void drawLine(int start_x, int start_y, int end_x, int end_y);			//simple line
	static void drawLine(int start_x, int start_y, int end_x, int end_y, int thickness);//solid line

	static void drawRectangle(int top_left_x, int top_right_y, int bottom_right_x, int bottom_right_y);	//simple rectangle
	static void drawFillRectangle(int top_left_x, int top_right_y, int bottom_right_x, int bottom_right_y);
	
	static void setColor(int red_value, int green_value, int blue_value);	//to set printing color
	
};



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
#include "List.h"
#include "Graphics.h"
class Map
{
public:
	Map(int);
	~Map();

	void drawMap();
	void setInit(int x,int y);
	void setFinal(int x,int y);
	void setRobotLocation(int x,int y);

	char** getMap();
	int getMapDim();

private:
	int n;
	int x, y;
	int size = 40;
	char **map;
};



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once
struct obstacle{
	int x, y;
	obstacle *next, *prev;
};
class List
{
public:
	List();
	~List();

	void add(int x,int y);
	bool isHere(int x, int y);

	obstacle* getList();
private:
	obstacle *head;
};



My compiler cried when I put this in. Of course, I can do nothing without the complete source, which you did not provide.

I would really recommend trying to find an alternative to conio.h. Surprisingly, my compiler (VS15) provides conio.h for me.

Why not try SDL or SFML for graphics? They're pretty easy to set up.
this is the full code

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include "Graphics.h"
#include <iostream>
#include <conio.h>
#include <Windows.h>

using std::cout;
using std::endl;

static HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
static HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
static UINT wDeviceID;
static COLORREF universal_color = RGB(255, 255, 255);
static HWND myconsole = GetConsoleWindow();
static HDC mydc = GetDC(myconsole);

void print(int ,int);

void Graphics::clr(int y){
	SetConsoleTextAttribute(out, y);
}

void Graphics::go(int a, int b){
	COORD cord;
	cord.X = a;
	cord.Y = b;
	SetConsoleCursorPosition(out, cord);
}

void Graphics::fontsize(int a, int b){
	PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx = new CONSOLE_FONT_INFOEX();
	lpConsoleCurrentFontEx->cbSize = sizeof(CONSOLE_FONT_INFOEX);
	GetCurrentConsoleFontEx(out, 0, lpConsoleCurrentFontEx);
	lpConsoleCurrentFontEx->dwFontSize.X = a;
	lpConsoleCurrentFontEx->dwFontSize.Y = b;
	SetCurrentConsoleFontEx(out, 0, lpConsoleCurrentFontEx);
}

void Graphics::fullscreen(){
	COORD NewSBSize = GetLargestConsoleWindowSize(out);
	NewSBSize.Y += 3;
	NewSBSize.X -= 2;
	SMALL_RECT DisplayArea = { 0, 0, 0, 0 };
	SetConsoleScreenBufferSize(out, NewSBSize);
	DisplayArea.Right = NewSBSize.X - 1;
	DisplayArea.Bottom = NewSBSize.Y - 1;
	SetConsoleWindowInfo(out, TRUE, &DisplayArea);
}

void Graphics::rgb(int r, int g, int b, int obj){
	CONSOLE_SCREEN_BUFFER_INFOEX CSBI;
	CSBI.cbSize = sizeof(CSBI);
	GetConsoleScreenBufferInfoEx(out, &CSBI);
	CSBI.ColorTable[obj] = RGB(r, g, b);
	SetConsoleScreenBufferInfoEx(out, &CSBI);
	SetConsoleTextAttribute(out, obj);
}

void Graphics::square(int X, int Y, int width, int length){
	for (int set1 = 0; set1 < length; set1++)
	{
		go(X, Y); Y++;
		for (int set2 = 0; set2<width; set2++){ cout << char(219); }cout << endl;
	}
}

void Graphics::Hsquare(int X, int Y, int width, int length)
{
	for (int set1 = 0; set1<length; set1++, Y++)
	{
		go(X, Y);
		if (set1 == 0 || set1 == length - 1) { for (int set2 = 0; set2<width; set2++) cout << char(219); continue; }
		cout << char(219); go(X + (width - 1), Y); cout << char(219);
	}
}

void Graphics::fsquare(int X, int Y, int width, int length)
{
	for (int set1 = 0; set1 < length; set1++, Y++)
	{
		go(X, Y);
		if (set1 == 0 || set1 == length - 1)
		{
			for (int set2 = 0; set2<width; set2++)
			{
				if (set2 == 0 && set1 == 0) { cout << char(201); continue; }
				if (set2 == width - 1 && set1 == 0) { cout << char(187); continue; }
				if (set2 == 0 && set1 == length - 1) { cout << char(200); continue; }
				if (set2 == width - 1 && set1 == length - 1) { cout << char(188); continue; }cout << char(205);
			}
			continue;
		}
		cout << char(186); go(X + (width - 1), Y); cout << char(186);
	}
}


void Graphics::drawRectangle(int x, int y, int width, int length){
	drawLine(x, y, x + width, y);
	drawLine(x, y, x, y + length);
	drawLine(x + width, y, x + width, y + length);
	drawLine(x, y + length, x + width, y + length);
}

void Graphics::drawFillRectangle(int x, int y, int width, int length){
	for (int i = y; i <= y + length; i++)
	{
		drawLine(x, i, x + width, i);
	}
}

void Graphics::drawLine(int x, int y, int x2, int y2){
	int interval_s, interval_e;
	if (x == x2){
		if (y < y2){
			interval_s = y;
			interval_e = y2;
		}
		else{
			interval_s = y2;
			interval_e = y;
		}
		for (int i = interval_s; i <= interval_e; i++)
		{
			print(x, i);
		}
	}
	else if (y == y2){
		if (x < x2){
			interval_s = x;
			interval_e = x2;
		}
		else{
			interval_s = x2;
			interval_e = x;
		}
		for (int i = interval_s; i <= interval_e; i++)
		{
			print(i, y);
		}

	}
	else{
		double m = ((double)y2 - (double)y) / ((double)x2 - (double)x);
		double c = (double)y - ((double)m*(double)x);
		if (x < x2){
			interval_s = x;
			interval_e = x2;
		}
		else{
			interval_s = x2;
			interval_e = x;
		}
		for (int X = interval_s, Y; X < interval_e; X++)
		{
			Y = ((double)m*(double)X) + c;
			print(X, Y);
		}
	}
}

void Graphics::drawCircle(int x, int y, int r){
	for (int X, Y, a = 0; a <= 360; a++)
	{
		X = x + r * cos(a);
		Y = y + r * sin(a);
		print(X, Y);
	}
}

void Graphics::drawCircle(int x, int y, int r, int thickness){
	if (thickness % 2 == 0){
		r -= thickness / 2;
		for (int i = 0; i < thickness; i++){
			r++;
			for (int X, Y, a = 0; a <= 360; a++)
			{
				X = x + r * cos(a);
				Y = y + r * sin(a);
				print(X, Y);
			}
		}
	}
	else{
		r -= thickness - 1 / 2;
		for (int i = 0; i < thickness; i++){
			r++;
			for (int X, Y, a = 0; a <= 360; a++)
			{
				X = x + r * cos(a);
				Y = y + r * sin(a);
				print(X, Y);
			}
		}
	}
}

void Graphics::drawFillCircle(int x, int y, int r){
	int aa;
	for (int X, Y, a = 0; a <= 360; a++)
	{
		X = x + r * cos(a);
		Y = y + r * sin(a);
		aa = x - X;
		if (aa > 0){
			aa *= 2;
			for (int i = 0; i < aa; i++)
			{
				print(X + i, Y);
			}
		}
		else
			print(X, Y);
	}
}

void print(int x, int y){
	SetPixel(mydc, x, y, universal_color);
}

void Graphics::setColor(int R, int G, int B){
	universal_color = RGB(R, G, B);
}





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
#include "List.h"
#include <iostream>

List::List(){
	head = NULL;
}

List::~List(){
	delete head;
}

void List::add(int x, int y){
	if (head == NULL){
		head = new obstacle();
		head->x = x;
		head->y = y;
		head->next = NULL;
		head->prev = NULL;
	}
	else{
		obstacle *temp = new obstacle();
		temp->x = x;
		temp->y = y;
		temp->next = head;
		head->prev = temp;
		temp->prev = NULL;
		head = temp;
	}
}

bool List::isHere(int x, int y){
	obstacle *triv = head;
	while (triv != NULL){
		if (triv->x == x && triv->y == y){
			return true;
		}
		triv = triv->next;
	}
	return false;
}

obstacle* List::getList(){
	return head;
}




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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "Map.h"
#include <random>
#include <iostream>
using std::cout;
Map::Map(int n)
{
	//generate random obstacles
	int obstacles_amount;
	obstacles_amount = n*n / 4;
	List obstacles = List();
	for (int i = 0; i < obstacles_amount; i++){
		obstacles.add(rand()%n,rand()%n);
	}

	this->n = n;
	map = new char*[n];
	for (int i = 0; i < n; i++){
		map[i] = new char[n];
		for (int j = 0; j < n; j++){
			if (obstacles.isHere(i,j)){
				map[i][j] = -1;
			}else
			map[i][j] = 0;	//0 mean open way
		}
	}
	x = -1;
	y = -1;
}

Map::~Map()
{
	delete map;
}

void Map::drawMap(){
	
	for (int i = 1; i <= n+1; i++)
	{
		Graphics::drawLine(size, i*size,size*(n+1),i*size);
	}
	for (int i = 1; i <= n+1; i++)
	{
		Graphics::drawLine(i*size, size, i*size, size*(n+1));
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (map[i][j] == -1){
				Graphics::setColor(100, 100, 100);
				Graphics::drawFillRectangle((i + 1)*size + 2, (j + 1)*size + 2, size - 4, size - 4);
			}
			if (map[i][j] == -3){
				Graphics::setColor(0, 255, 0);
				Graphics::drawFillRectangle((i + 1)*size+2, (j + 1)*size+2, size - 4, size - 4);
			}
			if (map[i][j] == -4){
				Graphics::setColor(255, 0, 0);
				Graphics::drawFillRectangle((i + 1)*size+2, (j + 1)*size+2, size - 4, size - 4);
			}

		}
	}
}

void Map::setInit(int x, int y){
	map[x][y] = -3;
}

void Map::setFinal(int x, int y){
	map[x][y] = -4;
}

void Map::setRobotLocation(int x, int y){
	if (this->x != -1 && this->y != -1){
			Graphics::setColor(0, 0, 0);
			Graphics::drawFillRectangle((this->x + 1)*size+1, (this->y + 1)*size + 1, size - 2, size - 2);
		
	}
	this->x = x;
	this->y = y;
	Graphics::setColor(255, 255, 255);
	Graphics::drawFillRectangle((x + 1)*size + 1, (y + 1)*size + 1, size - 2, size - 2);
}

char** Map::getMap(){
	return map;
}

int Map::getMapDim(){
	return n;
}
Last edited on
i really want the code work

because i have to discuss the doctor tomorrow and i dont know what to do

i dont know what to do to make it work with me :(
2 Unresolved Externals

Error	LNK2019	unresolved external symbol "public: static void __cdecl Graphics::setColor(int,int,int)" (?setColor@Graphics@@SAXHHH@Z) 
referenced in function "public: void __thiscall Map::drawMap(void)" (?drawMap@Map@@QAEXXZ)


Error	LNK2019	unresolved external symbol "public: static void __cdecl Graphics::fullscreen(void)" (?fullscreen@Graphics@@SAXXZ) 
referenced in function _main


You did not provide the implementation code for "Graphics::setColor" or "Graphics::fullscreen".
sorry my friend i have make a mistake and copy another code

i have corrected the code now you can check it
It seems to work on my machine. Is this what you're supposed to be seeing?

https://i.imgur.com/7rpdoPe.jpg
yeeesssssssssss thats what you seeing

pleaaaaaaaaaaaaaaaaase what shuld i do to work with me
do you use visual studio 2015 ???

how you make a project ??

witch type of project you chose ?? (( you chose empty project or win32 project or what ??))

please help me to make it work on my machine
I don't know why it isn't working for you. What compiler are you using? What OS are you on?

Me:
Windows 10
VC++15 (Visual Studio 15)
i have Windows 10

and i use Visual Studio 15

but what is VC++15 ???

by the way this is my first time i use Visual Studio 15 maybe i make some mistake while making the project or maybe i use the wrong compiler i really dont know what to do
Visual Studio allows one to work with a number of different programming languages. The variant of C++ it allows use of is typically referred to as VC++15.
You and I are using the same setup.

Visual Studio is just an IDE. Visual Studio 2015 actually has support for many languages. I'm using the default C++ compiler that comes with it, nothing special.
My project is set up as a Win32 Console Application, and the language is C++. Visual C++ is notorious for having some language rules that don't follow the standard, and it typically a little behind in C++ feature support. But Conio is like 20 years old, so that's not an issue.

Here is a copy of the Visual Studio project I'm using. Maybe that'll help you.

https://www.dropbox.com/s/ngr7vjc38rnywtb/ConioProject.zip?dl=0
thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you JayhawkZombie

itsssssssssssssssss wooooooooooooooooooooooooooorked


im really grateful for you
Glad it helped. There was probably something set up weird in your project, then.
Topic archived. No new replies allowed.