I'm trying to exit a while loop within a function but I don't think i'm writing the pointer correctly, c is new to me and reading examples online is confusing.

I would appreciate feed back on what I'm writing incorrectly.

```
int logOn(int *log);

int main(void)
{
    int log;
    log = 1;
    while(log = 1)
    {
        int logOn(log);
    }

    while(log = 2)
    {
        int mainMenu();
    }

    printf("\ngood bye");
}

int logOn(*par)
{
    char p;

    printf("would you like to log on (y/n): ");
    scanf("%s", &p);

    if(p="y")
    {
        par = 2;
    }
    else if(p="n");
    {
        par = 3;
    }
    else
    {
        printf("\nError entering command\n")
    }
    return 0;
}

```

I've updated my code and fixed a lot of the errors you guys helped my identify.

now for some reason it goes through my logon loop twice if i hit a key neither 'y' or 'n'

this is what my current code looks like

include
=======

```
int logOn(int *log);
int mainMenu(int *log);

int main(void)
{
    int log;
    log = 1;
    while(log == 1)
    {
        (void) logOn(&log);
    }

    while(log == 2)
    {
        mainMenu(&log);
    }

    printf("\ngood bye");
}

int logOn(int *par)
{
    char p;

    printf("would you like to log on (y/n): ");
    scanf("%c", &p);

    if(p == 'y')
    {
        *par = 2;
    }
    else if(p == 'n')
    {
        *par = 3;
    }
    else
    {
        printf("\nError entering command\n");
    }
    return 1;
}

int mainMenu(int *par)
{
    printf("\nMain Menu\n");
    *par = 3;
    return 0;
}

```

and this is what it is out putting when i dont hit 'y' or 'n'

```
 would you like to log on (y/n): e

 Error entering command
 would you like to log on (y/n): 
 Error entering command
 would you like to log on (y/n): 

```