int findWord(char ma[][iSize], char ca[],int iRing,int& X, int& Y){
	int ring=0,i=0,j=0,x=0,y=0,k=0,i2p=0,
		iLSide=0,iSSide=0;
	bool bOkay=true, bOver=false;
	ring = iRing--;
	iLSide=(iSize-(ring*2));
	iSSide=(iSize-((ring*2)+3));
	i2p=(iLSide*2)+(iSSide*2);
	x=y=i=ring;
	while(i>=ring && i<i2p && bOver==false){
		j=i;
		switch(i){
// WHAT'S WRONG WITH THIS?!? WHY CAN'T I ASK A CASE MINOR OR EQUAL?
			case =< iLSide:
				x=ring;
				y=j;
				break;				
			case =<((iLSide*2)-1):
				j-=i;
				y=iLSide;
				x=j;
				break;
			case <=((iLSide*2)-2):
				j-=(iLSide*2)-2;
				x=iLSide;
				y=j;
				break;
			case <=((iLSide*2)-3):
				j-=(iLSide*2)-2;
				y=ring;
				x=j;
				break;
		}
		if(ma[x][y]==ca[k]){
			if(k==0){
				X=x;
				Y=y;}
			else if(k==(sizeof(ca)/sizeof(ca[0])))
				bOver=true;
			k++;
		}
		else
			k=0;			
	}										
}

I posted all the code just to let you see it if you need it. If makes a ring in a matrix and search a word. All made with char.

So the problem is
error C2059: syntax error :
If I write case =<
And
error C2059: syntax error : '<='
If I write case <=

How should I do it? THank you.

Recommended Answers

All 4 Replies

You can't us variables with case...It must be a integral constant.

switch ( expression )
case constant-expression : statement
[default : statement]

Hey you're my angel: on all thread I've started, there's your sign =D.

Anyway, if it's not like in VisualBasic, Isn't there another way to do it? Always with Switch?
I don't want to nest IFs...

I would use an if statement

if (some condition)
{

}
else if (some other condition)
{

}
else if (more conditions)
{

}
else
{

}

Yeah that's the only solution -.- Why doesn't C++ support the case "variableisation"?!?

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.