I want to check, whether a password given by a user is correct or not.
I found the following manpage for crypt:
#define _XOPEN_SOURCE
#include <unistd.h>
char *crypt(const char *key, const char *salt);
... and thought, this is, what I have been looking for.
Take the users password, crypt it and compare the result with the
contents of /etc/passwd.
But the following went wrong:
first g++ didn't find the header of crypt. After a look at unistd.h I
changed
#define _XOPEN_SOURCE into
#define __USE_XOPEN
Now, the compilation succeeded, but the linker told me:
undefined reference to 'crypt'.
What is my mistake?