用C创建一个简单的注册和登录系统

经过一些帮助,如果可能的话。

我有一个班级项目,需要构建一个简单的登录和注册系统,该系统还需要输入验证密码和用户名,以满足长度/字符要求。 我是一个绝对的初学者,而且确实很挣扎。由于到目前为止我无法编译代码,因此我什至没有进行验证。我了解它可能看起来很凌乱,但是我确实在用C编程挣扎。

这是错误

login2.c: In function ‘login’:
login2.c:11:15: error: storage size of ‘l’ isn’t known
   11 |  struct login l;

任何帮助绝对是惊人的。 提前致谢!

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

login()
{
    char username[30],password[20];
    FILE *log;
    log=fopen("login.txt","r");
    struct login l;

    printf("\nPlease Enter your login credentials below\n\n");
    printf("Username:  ");
    fgets(username, 30, stdin);
    printf("\nPassword: ");
    printf("\n");
    fgets(password, 20, stdin);

    while(fread(&l,sizeof(l),1,log))
        {
        if(strcmp(username,l.username)==0 && strcmp(password,l.password)==0)

            {   
                printf("\nSuccessful Login\n");
            }
        else 
            {
                printf("\nIncorrect Login Details\nPlease enter the correct credentials\n");
            }
}

fclose(log);

}

struct login
{
    char fname[30];
    char lname[30];
    char username[30];
    char password[20];
}


registration()
{
    char firstname[15];
    FILE *log;
    log=fopen("login.txt","w");
    struct login l;

    printf("\nWelcome to your online course provider. We need to enter some details for registration.\n\n");
    printf("\nEnter First Name:\n");
    scanf("%c",l.fname);
    printf("\nEnter Surname:\n");
    scanf("%c",l.lname);

    printf("Thank you.\nNow please choose a username and password as credentials for system login.\nEnsure the username is no more than 30 characters long.\nEnsure your password is at least 8 characters long and contains lowercase, uppercase, numerical and special character values.\n"); 

    printf("\nEnter Username:\n");
    scanf("%c",l.username);
    printf("\nEnter Password:\n");
    scanf("%c",l.password);


    fwrite(&l,sizeof(l),1,log);
    fclose(log);

    printf("\nConfirming details...\n...\nWelcome, %c!\n\n",firstname);
    printf("\nRegistration Successful!\n");
    printf("Press any key to continue...");
        getchar();
    system("CLS");
    login();
}


int main()
{
    int option;

    printf("Press '1' to Register\nPress '2' to Login\n\n");
    scanf("%d",&option);

    if(option == 1)
        {
            system("CLS");
            registration();
        }

    else if(option == 2)
        {
            system("CLS");
            login();
        }
}