In the program i made tried to login and it does not work i am not sure what i did wrong.
[Click Here](http://www.onlinegdb.com/B15uh6kB_)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXUSERNAME 30
#define MAXPASSWORD  20

typedef struct
{
    char username[MAXUSERNAME];
    char password[MAXPASSWORD];
} pass;

int main()
{
    char userName[MAXUSERNAME];
    char password[MAXPASSWORD];
    pass t;
    int c;
    FILE *P= fopen("teachers.txt", "rb");

    if (P == NULL) 
    {
        printf("Error! opening file");
        exit(1);
    }

    do
    {
        printf("\nUsername:");
        fgets(userName,MAXUSERNAME,stdin);
        printf("\nPassword:");
        fgets(password,MAXPASSWORD,stdin);
        if((!strcmp(userName, t.username)) && (!strcmp(password, t.password)))
        {
           printf("Welcome to the Ahjin Private Primary School Repot Renerating System");
        }
        else
        {
            printf("\nLogin Failed \nEnter Username & Password Again\n");
            c++;
        }
    }
    while(c<=3);
    if(c>3)
    {
        printf("Login Failed");
        printf("Sorry,Unknown User.");
    }
}

What is the error...?
Your code looks fine

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.