I would like to know how I can know if a word is before another in a string. Here's my current code.
(I have some code after that, that's there's so many #include)
Thank you for your help
Thank you very much for what you give me, it work perfectly. However, I would like to change the "b" (const std::string& b) with "=", I can change the "a" with "x", but "=" is not a primary expression so it don't work.
I would like it to be : if x is before =, say true
Same things than before, but with "x" and "=".
Thank you again.
> However, I would like to change the "b" (const std::string& b) with "=",
> I can change the "a" with "x", but "=" is not a primary expression so it don't work.
> I would like it to be : if x is before =, say true
> Same things than before, but with "x" and "=".
I do not understand what this means - it is not clear to me at all.
Please post a clear example illustrating what it is that you are trying to do.
Here's what I want do do :
Normally, my code do ---> if b is before x, say true and if x is before b, say false.
What I want is ---> if = is before x, say true and if x is before =, say false
So, I think I have to do that to make it work :
My code is that :
----------
#include <iostream>
#include <math.h>
using namespace std;
// return true if in str, substring a appears before substring b
bool before( const string& str, const string& x, const string& b )
{
const size_t apos = str.find('x') ;
const size_t bpos = str.find('b') ;