<>> if(startBtn->label() == "Continue")
>> [..]
>> This would be better:
>> if(strcmp(startBtn->label(), "Continue") == 0)
>
> yes point taken, i did not check anything in the docs for that one,
> just wrote it in, i will change, but it does compile and run without issue,
> compiled with gcc and all warnings -w ?
It's not illegal to compare the pointer address of strings.
The compiler won't catch such mistakes regardless of what
the compiler warning levels are set to, as it won't know what your
intentions are.
But as coded, it won't compare the /contents/ of the strings,
which is what you wanted. So even if the label() is "Continue",
it will still fail, because the pointers will always be different.
This is standard C char* stuff which really must be understand clearly
or you'll get a lot of seemingly impossible behavior.
When you work with char* strings, the address of the string
is always being used by the compiler. So you have to use the
C library string functions like strcmp() to compare them.
It's only when you work with the more complex data types
like std::string that you can do things like == on strings
to compare them.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk