Question: I just want to use `crypt()` to generate an encrypted password,and I write a demo which invoke the `crypt()` method.
Here is my code

```
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("%s\n",crypt("abc","ab"));
    exit(0);
}

```

I compile it using `"gcc tem.c -lcrypt'` and when I run it, everything seems right, but a "segment error" shows up. so please tell me what's wrong with this simple program?

Answer: 
You need this:

```
#define _XOPEN_SOURCE

```

at the top of your source file, before any `#include`.

Alternatively compile with the gcc option `-D_XOPEN_SOURCE`.
Looks like it could be related to crypto library support.

Try adding:

```
#include <crypt.h>

[mstanislav@pardalislabs ~]$ gcc tem.c -lcrypt
[mstanislav@pardalislabs ~]$ ./a.out  
abFZSxKKdq5s6

```

Looks good for me!