check if character is NOT in string

Feb 14, 2014 at 5:14am
hello all. im making a sudoku solver.. my problem is that when it checks row, column and region for numbers, it seems to find the number that is present in all three rather than NOT present. here the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if(!rows[curRow].find(num))
			{
				if(!columns[curColumn].find(num))
				{
					if(!regions[curRegion].find(num))
					{
						oss << num;
					}
				}
			}
		}

		possible[box] = oss.str();
		oss.str("");


im going to leave evrything else out bc everything else is working perfectly and ik this is the problem.. why is looking for the num instead of looking to see if its NOT there??
Feb 14, 2014 at 5:48am
What's the implementation of find()?
Feb 14, 2014 at 6:11am
If rows[curRow] is a std::string, and num is a char

if( rows[curRow].find(num) == std::string::npos ) // if num is not in rows[curRow]
Feb 14, 2014 at 6:45am
thank you very much.. it was starting to frustrate me especially when it claimed it found a number that wasnt even there... >.< lol the help is appreciated!
Topic archived. No new replies allowed.