WARNING:Lots of messy code!! Lock if you must...

I've been looking at this for 2 hours and i cant figure out whats wrong.

Summary of program:
Display a Tic-Tac-Toe board. The user must click on one the of boxes. An 'X' appears in which ever box the user clicked. The computer then places his piece in the first free space. If the user places 3 'X's in a row it the screen should display the words "You win!". (I have not written code to check if the comp won yet)

I'm sure none of you want to look through lots of code but i don't know what else to do.

Main.cpp
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*Tic tac toe
*************
Summer 2011

/************************************************************************
********************************Headers**********************************
************************************************************************/
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"

#include "Screen.h"
#include "Board.h"
#include <string>

/************************************************************************
********************************Globals**********************************
************************************************************************/
Board gameBoard;
Screen mainScreen;

//mainScreen.


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Computer AI
class Comp
{
public:
	int HandleEvents();
	Comp();
private:	
};

Comp::Comp()
{
}

int Comp::HandleEvents()
{
	// block top row
	// attack
	// random
	if( gameBoard.Bbox[ 0 ][ 0 ] == 0 )
	{
		mainScreen.ApplySurface( 0, 0, gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[0][0] = 2;
		return 0;
	}
	else if( gameBoard.Bbox[ 0 ][ 1 ] == 0)
	{
		mainScreen.ApplySurface( 213, 0, gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[0][1] = 2;
		return 0;
	}
	if( gameBoard.Bbox[ 0 ][ 2 ] == 0 )
	{
		mainScreen.ApplySurface( 426, 0, gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[0][2] = 2;
		return 0;
	}
if( gameBoard.Bbox[ 1 ][ 0 ] == 0)
	{
		mainScreen.ApplySurface( 0, 160, gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[1][0] = 2;
		return 0;
	}
if( gameBoard.Bbox[ 1 ][ 1 ] == 0 )
	{
		mainScreen.ApplySurface( 213, 160, gameBoard.O,mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[1][1] = 2;
		return 0;
	}
if( gameBoard.Bbox[ 1 ][ 2 ] == 0)
	{
		mainScreen.ApplySurface( 426, 160,gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip(mainScreen.screen );

		gameBoard.Bbox[1][2] = 2;
		return 0;
	}
if( gameBoard.Bbox[ 2 ][ 0 ] == 0 )
	{
		mainScreen.ApplySurface( 0, 320, gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[2][0] = 2;
		return 0;
	}
	if( gameBoard.Bbox[ 2 ][ 1 ] == 0 )
	{
		mainScreen.ApplySurface( 213, 320, gameBoard.O, mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[2][1] = 2;
		return 0;
	}
	if( gameBoard.Bbox[ 2 ][ 2 ] == 0 )
	{
		mainScreen.ApplySurface( 426, 320, gameBoard.O,mainScreen.screen );

		//Update the screen
		SDL_Flip( mainScreen.screen );

		gameBoard.Bbox[2][2] = 2;
		return 0;
	}

	return 1;
}


/************************************************************************
********************************Functions********************************
************************************************************************/
void CleanUp()
{
	//Free the surfaces
	SDL_FreeSurface( mainScreen.background );
	SDL_FreeSurface( gameBoard.X );
	SDL_FreeSurface( gameBoard.O );

	SDL_Quit();
}

bool LoadFiles()
{
	//Load the images
	mainScreen.background			= mainScreen.LoadImage( "background.bmp" );
	gameBoard.X						= mainScreen.LoadImage( "x.bmp" );
	gameBoard.O						= mainScreen.LoadImage( "o.bmp" );

	//Open the font
	mainScreen.font = TTF_OpenFont( "lazy.ttf", 28 );
	// IF there was an error in loading the font
	if( mainScreen.font == NULL )
	{
		std::cout << "Font loading failed!";
		return false;
	}

	return true;
}

/************************************************************************
********************************Main************************************
************************************************************************/
int main( int argc, char* args[] )
{
	//quit flag
	bool gameDone = false;

	if( mainScreen.Init() == 1 )
	{
		std::cout << "Initialization failed";
		return 1;
	}

	if( LoadFiles() == 1 )
	{
		std::cout << "File loading failed";
		return 1;
	}

	// Set all the spaces to unoccupied
	for( int i = 0; i < 4; i++ )
	{
		for(int j = 0; j < 4; j++ )
		{
			gameBoard.Bbox[i][j] = 0;
		}
	}

	//Render the text
	mainScreen.message = TTF_RenderText_Solid( mainScreen.font, "You win!", mainScreen.textColor );

	// Draw the board
	mainScreen.ApplySurface( 0, 0, mainScreen.background, mainScreen.screen );
	//Update the screen
	if( SDL_Flip( mainScreen.screen ) == -1 )
	{
		std::cout << "SDL_Flip failed ";
		return 1;
	}

	Comp myComp;

	while( !gameDone )
	{
		while ( SDL_PollEvent( &gameBoard.event ) )
		{
			if(gameBoard.event.type == SDL_MOUSEBUTTONDOWN )
			{
				//Handle user events
				gameBoard.HandleEvents();
				if( gameBoard.CheckForWinner() == true )
				{
					mainScreen.ApplySurface( 216, 160, mainScreen.message, mainScreen.screen );
					SDL_Delay(2000);
					gameDone = true;
				}
				
				//Handle the comps evets
				myComp.HandleEvents();
			}
			if( gameBoard.event.type == SDL_QUIT)
			{
				gameDone = true;
			}
		}
	}
	
	//Update the screen
	if( SDL_Flip(mainScreen.screen ) == -1 )
		return 1;

	CleanUp();

	std::cin.get();
	std::cin.get();
    return 0;
}


Board.h
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
#ifndef BOARD_H
#define BOARD_H

#pragma once

#include "Screen.h"


 

class Screen;

class Board
{
public:
	SDL_Surface	*X;
	SDL_Surface *O;		
	SDL_Event event;
	Board();
	Screen* myScreen;
	void	SetClips();
	void	HandleEvents();
	bool	CheckForWinner();
	SDL_Rect	box[ 3 ][ 3 ];
	int			Bbox[ 3 ][ 3 ];

private:
};


#endif 


Board.ch
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include "Board.h"


bool Board::CheckForWinner()
{
	//The top left box is occupied by user
	if( Bbox[0][0] == 1)
	{
		//Check across
		if( Bbox[0][1] == 1 && Bbox[0][2] == 1 )
		{
			// User has won across the top
			// Display user has one and end stop the game
			return true;
		}
		//Check down first column
		if( Bbox[1][0] == 1 && Bbox[2][0] == 1 )
		{
			// User has won down the first column
			// Display user has one and end stop the game
			return true;
		}
		//Check diagonal
		if( Bbox[1][1] == 1 && Bbox[2][2] == 1 )
		{
			// User has won down the first column
			// Display user has one and end stop the game
			return true;
		}
	}
	// The Bottom right box is occupied by the user 
	if( Bbox[2][2] == 1 )
	{
		//Check across the bottom
		if( Bbox[2][0] == 1 && Bbox[2][1] == 1 )
		{
			// User has won across the top
			// Display user has one and end stop the game
			return true;
		}
		//Check up last column
		if( Bbox[1][2] == 1 && Bbox[0][2] == 1 )
		{
			// User has won down the first column
			// Display user has one and end stop the game
			return true;
		}
	}
	// The middle box is occupied
	if( Bbox[1][1] == 1 )
	{
		//Check diagonal from bottom left to top right
		if( Bbox[2][0] == 1 && Bbox [0][2] == 1 )
		{
			// User has won down the first column
			// Display user has one and end stop the game
			return true;
		}
		// Check the middle column
		if( Bbox[2][1] == 1 && Bbox[0][1] == 1 )
		{
			// User has won down the first column
			// Display user has one and end stop the game
			return true;
		}
	}

	//If user has not won
	return false;
}

void Board::SetClips()
{
	//Clip the board into 9 squares
	box[ 0 ][ 0 ].x	= 0;
	box[ 0 ][ 0 ].y	= 0;
	box[ 0 ][ 0 ].w	= 213;
	box[ 0 ][ 0 ].h	= 160;

	box[ 0 ][ 1 ].x = 213;
	box[ 0 ][ 1 ].y = 0;
	box[ 0 ][ 1 ].w = 213;
	box[ 0 ][ 1 ].h = 160;

	box[ 0 ][ 2 ].x = 426;
	box[ 0 ][ 2 ].y = 0;
	box[ 0 ][ 2 ].w = 213;
	box[ 0 ][ 2 ].h = 160;

	box[ 1 ][ 0 ].x = 0;
	box[ 1 ][ 0 ].y = 160;
	box[ 1 ][ 0 ].w = 213;
	box[ 1 ][ 0 ].h = 160;

	box[ 1 ][ 1 ].x = 213;
	box[ 1 ][ 1 ].y = 160;
	box[ 1 ][ 1 ].w = 213;
	box[ 1 ][ 1 ].h = 160;

	box[ 1 ][ 2 ].x = 426;
	box[ 1 ][ 2 ].y = 160;
	box[ 1 ][ 2 ].w = 213;
	box[ 1 ][ 2 ].h = 160;

	box[ 2 ][ 0 ].x = 0;
	box[ 2 ][ 0 ].y = 320;
	box[ 2 ][ 0 ].w = 213;
	box[ 2 ][ 0 ].h = 160;

	box[ 2 ][ 1 ].x = 213;
	box[ 2 ][ 1 ].y = 320;
	box[ 2 ][ 1 ].w = 213;
	box[ 2 ][ 1 ].h = 160;

	box[ 2 ][ 2 ].x = 426;
	box[ 2 ][ 2 ].y = 320;
	box[ 2 ][ 2 ].w = 213;
	box[ 2 ][ 2 ].h = 160;
}

Board::Board()
{
	for( int i = 0; i < 4; i++)
	{
		for( int j = 0; j < 4; j++ )
		{
			Bbox[i][j] = 0;
		}
	}

	SDL_Surface	*X	= NULL;
	SDL_Surface *O	= NULL;	
}

void Board::HandleEvents()
{
	//The mouse coords
	int x = 0;
	int y = 0;

	
	

	//If the user clicks a place on the board
	if( event.type == SDL_MOUSEBUTTONDOWN )
	{
		if( event.button.button == SDL_BUTTON_LEFT )
		{
			//Get the mouse coords
			x = event.button.x;
			y = event.button.y;

			//find the box the mouse was clicked in

			// mouse was clicked in right column
			if(  x > 426 )
			{
				// Mouse was click in top right
				if( y > 0 && y < 160 && Bbox[0][2] == 0)
				{
					myScreen->ApplySurface( 426, 0, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[0][2] = 1;
				}
				// Mouse was click in center right 
				else if( y > 160 && y < 320 && Bbox[1][2] == false)
				{
					myScreen->ApplySurface( 426, 160, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[1][2] = 1;
				}
				// Mouse was click in bottom right
				else if( y > 320 && Bbox[2][2] == 0)
				{
					myScreen->ApplySurface( 426, 320, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[2][2] = 1;
				}
			}
			// Mouse click in center column
			else if( x > 213 && x < 426 )
			{
				// Mouse was click in top center 
				if( y > 0 && y < 160 && Bbox[0][1] == 0 )
				{
					myScreen->ApplySurface( 213, 0, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[0][1] = 1;
				}
				// Mouse was click in center center
				else if( y > 160 && y < 320 && Bbox[1][1] == 0 )
				{
					myScreen->ApplySurface( 213, 160, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[1][1] = 1;
				}
				// Mouse was click in center bottom
				else if( y > 320 && Bbox[2][1] == 0 )
				{
					myScreen->ApplySurface( 213, 320, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[2][1] = 1;
				}
			}
			// Mouse clicked in left column
			else if( x > 0 && x < 213 )
			{
				// Mouse was click in top left
				if( y > 0 && y < 160 && Bbox[0][0] == 0 )
				{
					myScreen->ApplySurface( 0, 0, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[0][0] = 1;
				}
				// Mouse was click in center left
				else if( y > 160 && y < 320 && Bbox[1][0] == 0 )
				{
					myScreen->ApplySurface( 0, 160, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[1][0] = 1;
				}
				// Mouse was click in center left
				else if( y > 320 && Bbox[2][0] == 0 )
				{
					myScreen->ApplySurface( 0, 320, X, myScreen->screen );
					//Update the screen
					SDL_Flip( myScreen->screen );

					Bbox[2][0] = 1;
				}
			}
		}
	}
}




Screen.h
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
#ifndef SCREEN_H
#define SCREEN_H

#pragma once

#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"



#include <string>
#include <iostream>


class Screen
{
public:
	Screen();
	void ApplySurface( int x, int y, SDL_Surface* source, SDL_Surface* destination );
	bool Init();
	
	SDL_Surface* LoadImage(std::string filename);
	

	// Screen attributes
	const int SCREEN_WIDTH;
	const int SCREEN_HEIGHT;
	const int SCREEN_BPP;

	// Surfaces that will be used
	SDL_Surface *background;
	SDL_Surface *screen;
	
	//The font that will be used
	TTF_Font *font;
	SDL_Color textColor;
	SDL_Surface* message;
private:
};

#endif 




Screen.cpp
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
#include "Screen.h"

Screen::Screen()
	:SCREEN_WIDTH(640),SCREEN_HEIGHT(480), SCREEN_BPP(32)
{
	const int SCREEN_WIDTH		= 640;
	const int SCREEN_HEIGHT		= 480;
	const int SCREEN_BPP		= 32;

	SDL_Surface *background		= NULL;
	SDL_Surface *screen			= NULL;
	SDL_Surface* message		= NULL;

	SDL_Color textColor = { 0, 255, 0 };
	TTF_Font *font = NULL;
}

bool Screen::Init()
{
	// Initialize SDL video subsystem 
	if( SDL_Init( SDL_INIT_VIDEO ) == -1 )
	{
		std::cout << "SDL did not intialize";
		return false;
	}

	// initialize TTF
	if( TTF_Init() == -1 )
	{
		std::cout << "TTF did not intialize";
		return false;
	}

	//Set up the screen
	screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
	SDL_WM_SetCaption( "Tic-Tac-Toe", NULL );

	//If everything initialized fine
	return true;
}

//Applys the surface to the screen
void Screen::ApplySurface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
	//Make a temporary rectangle to hold the coordinates
	SDL_Rect coord;

	//Give the coordinates to the rectangle
	coord.x = x;
	coord.y	= y;

	//Draw the image
	SDL_BlitSurface( source, NULL, destination, &coord );
}

//Switch the format of the image to the same format as the screen
SDL_Surface* Screen::LoadImage( std::string filename )
{
	SDL_Surface* loadedImage = NULL;	// Temporary storage for the image that's loaded
	SDL_Surface* optimizedImage = NULL;

	loadedImage	= SDL_LoadBMP( filename.c_str() ); // Load the image in

	//If nothing went wrong in loading the image
	if( loadedImage != NULL )
	{
		//Create an optimized image
		optimizedImage	= SDL_DisplayFormat( loadedImage );

		SDL_FreeSurface( loadedImage );
	}
	else
	{
		std::cout << "Image not loaded succesfully";
	}

	return optimizedImage;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Screen::Screen()
	:SCREEN_WIDTH(640),SCREEN_HEIGHT(480), SCREEN_BPP(32)
{
	const int SCREEN_WIDTH		= 640;
	const int SCREEN_HEIGHT		= 480;
	const int SCREEN_BPP		= 32;

	SDL_Surface *background		= NULL;
	SDL_Surface *screen		= NULL;
	SDL_Surface* message		= NULL;

	SDL_Color textColor = { 0, 255, 0 };
	TTF_Font *font = NULL;
}


For this, since SCREEN_WIDTH, SCREEN_HEIGHT, and SCREEN_BPP are const, you might as well set them in the class definition. Also, this is a major issue: your declarations here are hiding their respective member variables. Same thing in your constructor to Board (surface pointers X and O are hiding their respective member variables). I suspect you're passing in an uninitialized textColor to your win message.

Do not redeclare member variables in the constructor. What ends up happening is the local variables are updated while the actual member variables remain uninitialized. Try this instead:

1
2
3
4
5
6
7
8
9
10
Screen::Screen()
	:SCREEN_WIDTH(640),SCREEN_HEIGHT(480), SCREEN_BPP(32)
{
	background	= NULL;
	screen		= NULL;
	message		= NULL;

	textColor = { 0, 255, 0 };
	font = NULL;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
Board::Board()
{
	for( int i = 0; i < 4; i++)
	{
		for( int j = 0; j < 4; j++ )
		{
			Bbox[i][j] = 0;
		}
	}

	X	= NULL;
	O	= NULL;	
}


Also, are your images loading at least? If not, try including their full file paths.

Is your game finishing? If not, try breaking from the while ( SDL_PollEvent( &gameBoard.event ) ) loop when gameDone is set to true.
Last edited on
Thanks for the reply!

I changed what you said and now this code:
 
textColor = { 0, 255, 0 };


is giving my these errors:
1
2
3
4
5
6
1
1>  Screen.cpp
1>c:\users\david\documents\visual studio 2010\projects\tic-tac-toe\screen.cpp(10): error C2059: syntax error : '{'
1>c:\users\david\documents\visual studio 2010\projects\tic-tac-toe\screen.cpp(10): error C2143: syntax error : missing ';' before '{'
1>c:\users\david\documents\visual studio 2010\projects\tic-tac-toe\screen.cpp(10): error C2143: syntax error : missing ';' before '}'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


What was happening before was when i clicked debug the cmd window would come up and then close.
Try this:

1
2
3
textColor.r = 0;
textColor.g = 255;
textColor.b = 0;
Thanks again, but its still not working :(. I know the whole program is poorly organized but i've learned from my mistake and i'll make sure to plan more next time! But for now, the program just shows the console window and then it closes the console window.

Here are the errors if it helps.
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
'Tic-Tac-Toe.exe': Loaded 'C:\Users\david\Documents\Visual Studio 2010\Projects\Tic-Tac-Toe\Debug\Tic-Tac-Toe.exe', Symbols loaded.
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Users\david\Documents\Visual Studio 2010\Projects\Tic-Tac-Toe\Debug\SDL.dll', Binary was not built with debug information.
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Users\david\Documents\Visual Studio 2010\Projects\Tic-Tac-Toe\Debug\SDL_ttf.dll', Binary was not built with debug information.
'Tic-Tac-Toe.exe': Loaded 'C:\Users\david\Documents\Visual Studio 2010\Projects\Tic-Tac-Toe\Debug\libfreetype-6.dll', Binary was not built with debug information.
'Tic-Tac-Toe.exe': Loaded 'C:\Users\david\Documents\Visual Studio 2010\Projects\Tic-Tac-Toe\Debug\zlib1.dll', Binary was not built with debug information.
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL', Cannot find or open the PDB file
'Tic-Tac-Toe.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Tic-Tac-Toe.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
The program '[3888] Tic-Tac-Toe.exe: Native' has exited with code 1 (0x1).
Last edited on
This is where I can't help much any more. Did you try adding the whole file paths to background.bmp, x.bmp, and o.bmp? Try using the whole file path (including double back slashes if on Windows).

Barring that, this is where using a step-through debugger will help the most. Put a break point on the first line in main. Then, step over the code line by line until it crashes. That will give you a clue. Good luck!
Try doing a Recompile All/Recompile Solution. That happens when temporary files go poof.
@LB
I cant find a Recompile All button? Im using VC++ 2010.

@Shacktar
Even if i put return 0 on the first line of int main it still says those errors, exept it says exited with code 0 instead of code 1.

:(
Under the "Build" menu, there's "Rebuild Solution".

Even if i put return 0 on the first line of int main it still says those errors, exept it says exited with code 0

Well, it would exit with code 0 because of "return 0". When it says "exited with code 1", that means your program is finishing at one of your "return 1" statements.

Does the following make any sense to you?

shacktar wrote:
Put a break point on the first line in main. Then, step over the code line by line until it crashes. That will give you a clue.

If not, I would suggest learning about the Visual Studio debugger, pronto. This tutorial seems good enough: http://www.youtube.com/watch?v=z5gBIizwsY0
Remember to watch it in 720p and full screen like the uploader suggests.

If you can't debug, try rebuilding the solution under the "Debug" configuration.
Topic archived. No new replies allowed.