BleepingComputer.com: C++ character comparison

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

C++ character comparison

#1 User is offline   sausage 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 317
  • Joined: 01-November 08
  • Gender:Male
  • Location:Louisville Colorado

Posted 09 April 2009 - 10:19 PM

So, in my ASCII ROG (yes, that one) I am trying to compare the wall (#219 on the ASCII chart) to 219 (pretty much just check if I am moving into it.)

This segment, for some reason does not check character value but array position... I am almost positive that there is a special way to compare character values (in java is string.equals()) But I am not sure what it is or what to look up to find it

if(map[index[0]][index[1]-1] != 219) // index[0] is the X coordinate and index[1] is the Y coordinate, this is the check when moving down


I would appreciate the library the function is located in :thumbsup:

This post has been edited by sausage: 09 April 2009 - 10:20 PM

If I'm posting, I probably have something horribly wrong with my computer, there's no obvious explanation for it, that's just the way it is.

#2 User is offline   Billy O'Neal 

  • Bleepin Engineer GRADUATE
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 10,403
  • Joined: 17-January 08
  • Gender:Male
  • Location:Cleveland, Ohio

Posted 09 April 2009 - 11:53 PM


#3 User is offline   sausage 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 317
  • Joined: 01-November 08
  • Gender:Male
  • Location:Louisville Colorado

Posted 10 April 2009 - 07:26 AM

char why?

EDIT: or to be more specific
char map[30][30];

This post has been edited by sausage: 10 April 2009 - 07:31 AM

If I'm posting, I probably have something horribly wrong with my computer, there's no obvious explanation for it, that's just the way it is.

#4 User is offline   Billy O'Neal 

  • Bleepin Engineer GRADUATE
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 10,403
  • Joined: 17-January 08
  • Gender:Male
  • Location:Cleveland, Ohio

Posted 10 April 2009 - 10:50 AM

No.. I mean what does the map variable contain when you're trying to work with it?

What is your expected behavior?
What are you actually getting?

Billy3

#5 User is offline   sausage 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 317
  • Joined: 01-November 08
  • Gender:Male
  • Location:Louisville Colorado

Posted 10 April 2009 - 04:38 PM

it contains a bunch of dots (walkable space) and some walls (ASCII character #219)
defined as
for(int i = 0; i < 30; ++i)
	{
			map[0][i] = 219;
			map[29][i] = 219;
			map[i][0] = 219;
			map[i][29] = 219;
	}
	
	for(int i = 1; i < 29; ++i)
	{
			for(int j = 1; j < 29; ++j)
			{
					map[j][i] = '.';
			}
	}


the expected behavior is that you can move along the dots and not move into the walls

I am getting the ability to walk through the dots and through the walls.

EDIT: Error fixed, for some reason it was declaring the wall as a -37 value??? not sure why it is but I fixed it and now I don't walk through walls hooray!

This post has been edited by sausage: 10 April 2009 - 05:05 PM

If I'm posting, I probably have something horribly wrong with my computer, there's no obvious explanation for it, that's just the way it is.

#6 User is offline   Billy O'Neal 

  • Bleepin Engineer GRADUATE
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 10,403
  • Joined: 17-January 08
  • Gender:Male
  • Location:Cleveland, Ohio

Posted 10 April 2009 - 08:47 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users