Updated code that still doesn't work:
Code:
/* init_user_s(): initialises a user structure with specified values */
void init_user_s (user_t* u, int uid, char* uname, char* pwd)
{
uname = (char*)calloc (sizeof(char), strlen(uname) + 1);
pwd = (char*)calloc (sizeof(char), strlen(pwd) + 1);
if (uid != 1) // user_id 1 reserved for administrator
{
printf ("Error, user ID 1 reserved.\n");
return;
}
u->user_id = uid;
strncpy (u->username, uname, strlen(uname) + 1);
strncpy (u->password, pwd, strlen(pwd) + 1);
}