I want to create a C program to create a doubly linked list of character arrays. The input would be given like in a menu, with particular conditions for adding an element, breaking away etc. Initially I am only accepting the character input 'V' to create the list, otherwise the program breaks off.
But when I enter 'V' as the input (for the first time) and then a character array the else statement (inside the while loop) also gets executed which should be impossible. Can someone explain why this is happening? It may have some obvious mistake that I just cannot see.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct website
{
    char web[30];
    struct website* forward;
    struct website* backward;
};
struct website* create(char* val, struct website* back) {
    struct website* curr = (struct website*)malloc(sizeof(struct website));
    if (curr) curr->forward = NULL;
    if (curr) curr->backward = back;
    if (curr) strcpy(curr->web, val);
    return curr;
}
int main() {
    struct website* websites = NULL;
    while (1) {
        char x;
        scanf("%c", &x);
        if (x == 'V') {
            char y[30];
            scanf("%29s", y);
            websites = create(y, websites);
        }
        else {
            printf("yes");
            break;
        }
    }
    printf(" bye ");
    return 0;
}
 
    