class Timerange{
    public:
        Start_time start;
        End_time end;
        Timerange(string initstring){
            //initstring xx:xx X, x:x
            //X->weekday
            string current="";
            unsigned short mode=0;
            string timeA;
            string weekday;
            string timeB;
            for(unsigned short i = 0; i<initstring.length(); i++) {
                char c = initstring[i];
                if (c==' '){
                    if (mode==0)
                        timeA = current;
                    else if (mode==1)
                        weekday = current;
                    else if (mode==2)
                        timeB = current;
                    mode++;
                    current ="";

                };
                else{ //here
                    current+=c;
                };
            };
        };
};

it gives me error: 'else' without previous 'if''
but there is an if! What's going on?

Number one. Why all the semi-colons?

Here. Can you spot the error now?

class Timerange
{
public:

    Timerange(string initstring)
    {
        string current = "";
        unsigned short mode = 0;
        string timeA;
        string weekday;
        string timeB;
        for(unsigned short i = 0; i<initstring.length(); i++)
        {
            char c = initstring[i];
            if (c == ' ')
            {

            };//hint its here
            else
            { 

            }
        }
    }
};
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.