Write a password authentication program using a Binary Search Tree for a fast
username search. Your program must meet the following requirements:
Inputs:
Before doing an authentication, read a file named “authen.pwd” that stores pairs of username and password.
Wait for a command from a user and respond accordingly. For example:
>Add s1limth
passwd: abc123
>Delete s1limth
>Verify s1limth >Verify s1limth
passwd: 321cba passwd: abc123
Invalid Password! Password Confirmed!

>List
s1limth:abc123
s1pornu:456def
>Quit
Outputs:
Update the “authen.pwd” file before exiting the program.
The “authen.pwd” file must conform the following format:
s1limth:abc123
s1pornu:456def
Your program must be named “pwdauth.c” for the source code and
“pwdauth” for the executable.

Recommended Answers

All 9 Replies

if you don't know where to start, here's a hint

int main()
{
  // put your code here
}

YOu have to first post ur effort my friend before expecting any kind of help from the forum members.

if you don't know where to start, here's a hint

You forgot the return:

int main()
{
    // put your code here

    return 0;
}

no I didn't forget it -- it not required in current c or c++ standards. Default is return 0. But some older compilers will complain.

no I didn't forget it -- it not required in current c or c++ standards. Default is return 0. But some older compilers will complain.

Right. C99 and C++ adds return 0; automatically.

Sloppy... Just because it can be done doesn't mean it should...
After all, gets() still exists, doesn't it? ;)

Sloppy... Just because it can be done doesn't mean it should...
After all, gets() still exists, doesn't it? ;)

It's a good programming habit to write return 0; at the end but there's no harm in not writing it now.
gets() issue is different. It's a dangerous call.

Sloppy... Just because it can be done doesn't mean it should...
After all, gets() still exists, doesn't it? ;)

Mr. WaltP please see the context in which the comment was made by Mr. Ancient Dragon. He was actually trying to tell the new programmer ie the OP to first post his own effort. It was not sloppy progg.

int main (void)
{
 // your code goes here could mean a lot of things 
// it can also include the return 0 since its part of the code ;)
}

If u go out to tell the beginner programmer everything in a single post without even knowing his skilll set then even this would not suffice

int main (void)
{
// write some code to take inuput from user
// please dont use scanf () for taking the input since it leaves the
// remaining data in the input stream 

// avoid usign gets () after scanf () since it may read in the data left
// from the prev scanf attempt.

// dont ever try to clear the input stream using fflush (stdin) since its
// behaviour is undefined

// and dont forget that main returns an int as a signal to the operting
// system about its execution status.

// and many more blah blah blah
}

I hope now u understand teh meaning of Mr.Ancient Dragon's post.

Take care,
Bye.

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.