while( i < lineCount) {
	current = 1;
		
		while (nList[i-1] = nList[i]&& i < lineCount) {

			current++;
			i++;

			if (current > highest);
				
			highest = current;
			arrayposition = i;

			multiMode = false;

		} else if(current == highest) {
		multiMode = true;
		}
		i = i + 1;
		}

	if (multiMode == true)

	return -1;

	else return arrayposition;

The error points to the line

} else if(current == highest) {

reading "illegal else without matching if"

I have just started learning C++ and would appreciate any help you can offer, it's probably a simple mistake :o

>reading "illegal else without matching if"
It's pretty straightforward. To have an else clause you first need an if clause. Since the closest match is a while loop, you've created a syntax error.

Ok.... I know you're new to this so I wont go to hard on ya....

There's a couple of problems going on here, for your error though, your code is trying to apply an else to a while loop which just isn't possible.

Formatting your code will help a lot, take a look:

while( i < lineCount) {
	current = 1;
	while (nList[i-1] = nList[i]&& i < lineCount) {
		current++;
		i++;
                // you had a semicolon(;) ending the following line, big oops
		if (current > highest){
			highest = current;
			arrayposition = i;
			multiMode = false;
		} else if(current == highest) {
		        multiMode = true;
		}
		i = i + 1;
	}

	if (multiMode == true){
        	return -1;
        }
	else {
                return arrayposition;
        }
}

That semicolon on the end of your if line basically ended the IF before it had done anything, therefore the code on the lines after it was being executed no matter what the conditions were. When it got to the else the compiler was litterally confused because it couldn't find the IF you were talking about. I didn't change the code much else besides that, just added some braces for clarity.

I'd guess that you intended this:

if (current > highest);

to be this:

if (current > highest){
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.