Your code is not coded properly and has lots of errors. And also I see that you are using C and not C++. Working with strings in C is a pain but since you started it in C:
#include <stdio.h>
#include <string.h>
int user_name(char name[]);
int password(char passw[]);
int list();
int main()
{
//Declare variables to hold username and password and give a good size to stop overflow errors
char usrn[15];
char pass[15];
printf("Enter username: ");
scanf("%s", &usrn); //Get the username
if(user_name(usrn) == 1) //Check whether the username is correct or not; exit if wrong
{
return 0;
}
printf("Enter password: ");
scanf("%s", &pass); //Get the password
if(password(pass) == 1) //Check whether the password is correct or not; exit if wrong
{
return 0;
}
puts("\"You are authorized user\"");
list();
return 0;
}
int user_name(char name[])
{
if(strcmp(name, "student") != 0) //Compares the user's input and the correct username
{
puts("WRONG USERNAME!");
return 1; //Returns 1 if not same
}
return 0; //Return 0 if same (no need 'else' because if its same the if statement won't be executed)
}
int password(char passw[])
{
if(strcmp(passw, "cs") != 0) //Compares the user's input and the correct password
{
puts("WRONG PASSWORD!");
return 1; //Returns 1 if not same
}
return 0; //Return 0 if same
}
int list()
{
}