I'm trying to make a script that helps verify a persons age on whether or not someone can go into a bar, then if they can order or not but seem to be having an issue with a "expected primary-expression before '{' token" on line 23.
Here is my code:

#include <iostream>
#include <string>
using namespace std;


int main()
{
    string name;

    cout << "Hello, what is your name?: ";  //asking user for their name string
    getline(cin, name);

    cout << "Hello, " << name << endl;  // output saying hello to the user by their inputted name

    int age;

    cout << "How old are you," << name << " ? ";
    cin >> age;

    if (age >= 21)
    {
        cout << "Welcome " << name << " You can come into the bar!" << 
                {
                char answer,
                cout << "Would you like a drink, " << name << "? Type y for yes n for no." <<;
                cin >> answer;
                if (answer == 'y');
                {
                    cout << "Here's your drink, " << name << ".";
                }
                else

                    cout << "Maybe next time then." << ;
            }
            }
    else
    {
        cout << "Sorry " << name << " you're too young to be in the bar." << endl;
    }
return 0;
}

For starters the line

cout << "Welcome " << name << " You can come into the bar!" << 

is incomplete. And

    char answer,

is also invalid. Your compiler would have complained about this. Fix your syntax errors (there are many others) and get back to us if you still have a problem.

Be a part of the DaniWeb community

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