Syntax error: "return"?

I've been looking at c++ for a while now, but all I have been able to do so far is basic console stuff. I wanted to do some more stuff so I started looking at SDL. I installed SDL no problem, but when I tried to follow this (http://pgdc.purdue.org/sdltutorial/01/) tutorial on SDL basics, the output from Visual Studio 2008 was:
1
2
3
4
1>c:\sdl_test\sdl_test\sdl2\main.cpp(122) : error C2059: syntax error : 'return'
1>c:\sdl_test\sdl_test\sdl2\main.cpp(123) : error C2059: syntax error : '}'
1>c:\sdl_test\sdl_test\sdl2\main.cpp(123) : error C2143: syntax error : missing ';' before '}'
1>c:\sdl_test\sdl_test\sdl2\main.cpp(123) : error C2059: syntax error : '}'

The code I ended up with was:
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
/* -- Include the precompiled libraries -- */
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif

#include <stdlib.h>
#include "SDL.h"

#define TRUE 1
#define FALSE 0

int main(int argc, char *argv[])
{
	SDL_Surface *screen;
	SDL_Surface *picture;
	SDL_Event event;
	SDL_Rect pictureLocation;
	int leftPressed, rightPressed, upPressed, downPressed;
	const SDL_VideoInfo* videoinfo;
	
	atexit(SDL_Quit);

	/* Initialize the SDL library */
	if( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}

	screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF | SDL_HWSURFACE);
	if ( screen == NULL ) {
		fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
			SDL_GetError());
		exit(1);
	}
	
	videoinfo = SDL_GetVideoInfo();

	printf("%i", videoinfo->blit_hw);

	// Load Picture
	picture = SDL_LoadBMP("Iapetus.bmp");

	if (picture == NULL) {
		fprintf(stderr, "Couldn't load %s: %s\n", "SDL_now.bmp", SDL_GetError());
		return 0;
	}

	while(TRUE) {
		if (leftPressed) {
			if (pictureLocation.x > 0)
				pictureLocation.x--;
		}
		if (rightPressed) {
			if (pictureLocation.x < 640-picture->w)
				pictureLocation.x++;
		}
		if (upPressed) {
			if (pictureLocation.y > 0) {
				pictureLocation.y--;
			}
		}
		if (downPressed) {
			if (pictureLocation.y < 480-picture->h) {
				pictureLocation.y++;
			}
		}

		SDL_FillRect(screen, NULL, 1000);
		SDL_BlitSurface(picture, NULL, screen, &pictureLocation);
		SDL_Flip(screen);

		if( SDL_PollEvent( &event ) ){
		/* We are only worried about SDL_KEYDOWN and SDL_KEYUP events */
		switch( event.type ){
			case SDL_KEYDOWN:
				switch(event.key.keysym.sym) {
					case SDLK_LEFT:
						leftPressed = TRUE;
						break;
					case SDLK_RIGHT:
						rightPressed = TRUE;
						break;
					case SDLK_DOWN:
						downPressed = TRUE;
						break;
					case SDLK_UP:
						upPressed = TRUE;
						break;
					case SDLK_ESCAPE:
						exit(0);
					default:
						break;
			}
				break;
	
				case SDL_KEYUP:
					switch(event.key.keysym.sym) {
						case SDLK_LEFT:
							leftPressed = FALSE;
							break;
						case SDLK_RIGHT:
							rightPressed = FALSE;
							break;
						case SDLK_DOWN:
							downPressed = FALSE;
							break;
						case SDLK_UP:
							upPressed = FALSE;
							break;
						default:
							break;
					}
					break;

					default:
					break;
				}
			}
		}
	}
	return 0;
}
I have no idea why it told me "return" was a syntax error and I had missing ";", having rechecked the whole code twice, and would appreciate any help in resolving my problems.

Thanks

Bubba Ex
closed account (z05DSL3A)
I think you have to many closing braces '}' at the end of main..
And perhaps missing some semi-colons too.
Sometimes it's good to read what the errors say ;-)
Topic archived. No new replies allowed.