forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

3 simple c++ questions

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Fri Jan 27, 2006 1:23 am    Post subject: 3 simple c++ questions Reply with quote

Hi folks, i have two question which bother me for a while now and i have always worked around it but it is time to solve the stupid questions:

1.) how do i declare a boolean? bool gives errors in the compiler

2.) what is wrong with this:

Code:
if (iField[x + 1][y] == BlockKind) || (iField[x + 1][y] == BlockKind + 2) {


with this code:

Code:
main.c: In function 'CheckSurroundingField':
main.c:110: error: syntax error before '||' token

i want to just look if one of the tow i right and the execute the code

3) what is wrong with this:

Code:
int CheckSurroundingField(int x, int y, int BlockKind){

the compiler says i didn't declare the x and y and BlockKind but these are the values i pass through how do i do this?

greets ghoti (a former visual basic programmer...)
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Fri Jan 27, 2006 1:43 am    Post subject: Reply with quote

Hi,

You declare a boolean as

bool some_var_name;

Just to make sure, that this is a C++ feature, it does not work in C.

About the last two questions, could you post the complete function instead. It might very well be something else than the two lines posted, that is the rootcause for the problem.
_________________
Br, Sandberg
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Fri Jan 27, 2006 1:52 am    Post subject: Reply with quote

Okay i know use integers to do the same a boolean in my psp app so i'll stick with that.

I have corrected the last two they belonged together because when i solved the first i didn't get any error anymore like the 3th question so that is solved.

solving was removing the )(. i didn't know that i couldn't be done like i did:

if (x==a || x==b) {}

but not this:

if (x==a) || (x==b) {}

thank you for the answer
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Fri Jan 27, 2006 1:57 am    Post subject: Reply with quote

Ghoti wrote:

solving was removing the )(. i didn't know that i couldn't be done like i did:

if (x==a || x==b) {}

but not this:

if (x==a) || (x==b) {}

thank you for the answer


Damn, I should have seen that :)

You need to have outer () on the expression. like below

if ((x==a) || (x==b)) {}

That'll work ..
_________________
Br, Sandberg
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group