It may be the compiler, but it just doesn't work.
The program it's suppose to return the string "a m".

#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
    std::string x = "hola mundo";
    std::cout << fromto(x.c_str(),"l","u") << std::endl;
    return 0;
}
const char* fromto(const char* str,const char* from,const char* to,bool include_from_and_to = true)
{
    if(!MUO_char_from(str,from,include_from_and_to)){return "\0";}
    int x = MUO_char_to(str,from,to,include_from_and_to);
    if(x == 0){return "\0";}
    if(include_from_and_to){x += strlen(to);}
    char* res = new char[x];
    int y = 0;
    for(;y < x;y++){res[y] = str[y];}
    res[y] = '\0';
    return res;
}
bool MUO_char_from(const char* &str,const char* &from,bool &include_from_and_to)
{
    int x;
    int y = strlen(from);
    while(*str != '\0')
    {
        x = 0;
        while(str[x] == from[x])
        {
            x++;
            if(y == x)
            {
                 if(include_from_and_to){return true;}
                 else
                 {
                     x = 0;
                     while(x < y)
                     {
                         str++;
                         x++;
                     }
                     return true;
                 }
            }
        }
        str++;
    }
    return false;
}
int MUO_char_to(const char* &str,const char* &from,const char* &to,bool &inlcude_from_and_to)
{
    unsigned int x = 0;
    if(inlcude_from_and_to){x = strlen(from);}
    unsigned int y = x,z = 0;
    while(str[y] != '\0')
    {
        while(str[x] == to[z])
        {
            if(to[x] == '\0'){return y;}
            x++;
            z++;
        }
        y++;
        x = y;
        z = 0;
    }
    return 0;
}

sorry for posting the hole thing, i'm not sure whts the problem.

It just doesn't work? Then you did it wrong.

When asking for help, be specific. What does it do instead? And try to pinpoint where the problem might be.

Did you add output statements to see if important steps of the process have done their job correctly?

okey... MUO_char_to() returns 0 when it should return 4

I repeat:
Did you add output statements to see if important steps of the process have done their job correctly?

Sorry I found the problem, how can I close this post?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.