| purefan (15) | ||||
|
Hello all! Read a little about using regex in C++ and everything pointed to Boost, read about using Boost and it seemed beyond me to actually get it running.. Not a big deal since my project is rather simple (way simple for what you wise ones must've dealt with). at this point I am trying to match one character from a string to a period ("."), so I have this function so far:
Fairly straightforward I guess, but sure enough strcmp complains that the first argument is not const char* Here is the output:
Any help or guidance will be much appreciated :) Have a nice day | ||||
|
|
||||
| Moschops (3710) | |
strcmp is a function that accepts two arguments; both arguments must be of type "pointer to const char". You have tried to pass sMove[iPos] which is a char. The compiler quite rightly does not know how to turn this char into a pointer to a constant char, so fails.Do not pass a char; pass a pointer to a constant char. The compiler will probably also be happy with a pointer to a char. http://www.cplusplus.com/reference/string/string/operator[]/ | |
|
|
|
| andywestken (1477) | |
If you just want to test if the character at iPos is a '.', you need... || sMove[iPos] == '.')Note the single quotes. Andy P.S. strcmp should not be be used with std::string. Instead use its operator== ... || sMove == ".")You can also use the compare method, but I wouldn't use this just test for eqality. ... || sMove.compare(".") == 0) | |
|
Last edited on
|
|
| purefan (15) | |||
|
Thanks all! In the end this did the trick:
Much obliged! | |||
|
|
|||