Hello, I have a question to ask whoever can help me.
I've have dev - c++. see I've been using C++ for a while now but i'm still sorta a newbie...
i havn't had this problem before but i've been trying to do a password program just to play around with it
and any way whenever i type in the command 'else'
i try to comple it bu it says this:

error: expected primary-expression before "else"
error: expected `;' before "else"

and theres not a thing wrong with my file... is there?
heres my program:

#include <iostream>
#include <windows.h>
using namespace std;

int main ()
{
    string password;
    cout <<"Please input a password to enter successfully:" <<endl;
    getline (cin, password);
    if (password == "pen15");
    {
                 cout <<"Welcome";
    } 
    else
    {
        cout <<"invalid"<<endl;
        system ("pause");
        return 0;
    }
    system ("pause");
    return 0;
}

like.. where the hell am i supposed to add that other semi colon?
i try puting the semi colon right in front of else - dosn't work
i put it affter the } before the else - dosn't work...
plz help me...

if (password == "pen15");

You have an extra semicolon at the end there.

[edit] You also need to include <string> because you use the string class and getline.

Please don't use system("pause") ...
Use cin.get(); instead.
(explanation)

BTW, why are you including windows.h ( #include <windows.h> )? You aren't using anything of it.

:)

Here you go. Also as a side note, system ("pause") is a bad habit.

#include <iostream>
using namespace std;

int main ()
{
string password;
cout <<"Please input a password to enter successfully: ";
cin>>password;
if (password == "pen15")
cout <<"Welcome\n\n";
else
cout <<"invalid"<<endl;
cin.get();
return 0;
}

Thank you, my program is working correctly!

Here you go. Also as a side note, system ("pause") is a bad habit.

So is:
1) posting code the OP should be writing
2) posting code that is not formatted

Please do not post answers to questions. This forum is not a homework service. And that service should include properly formatted code segments.

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.