Bug #9126 2006-10-15 06:12

skisoccer13

comparing strings with elements of vectors

It seems that the following if statement causes my program to crash. Given that 'word' is a string, words is a vector of strings, and 'i' is a position in the vector.

if (word != words[i] ) {

...

}

If I change the code to read:

if (word != (words[i])) {

...

}

I no longer crash.

Category
Compiler
Group
 
Status
Closed
Close date
2006-10-18 00:00
Assigned to
 
skisoccer13 2006-10-15 06:20

Also, using

if (words[i] != word) {

...

}

works because the vector is executed first. It seems like within conditional statements if the vector is not first and/or not enclosed by parentheses then it doesn't execute in the proper order.

ceniza 2006-10-17 23:56

Sorry but it has nothing to do with Code::Blocks. Please report it to the developers of the compiler you're using.

ceniza 2006-10-17 23:59

Sorry but it has nothing to do with Code::Blocks. Please report it to the developers of the compiler you're using.