0
#define _XOPEN_SOURCE   //DES cypher
#include <crypt.h>      //
#include <cs50.h>       //GetString, booleans, and string datatype
#include <stdio.h>      //printf
#include <string.h>     //strlen
#include <unistd.h>     //DES cypher

int main (void)
{
    printf("%s\n", crypt("passwd", 1000));
}

In the code above I am simply testing the crypt function, but it keeps throwing me an error. Clang tell s me that there is an "incompatible integer to pointer conversion." I don't understand how to use the crypt class, I've looked online, on the man pages, and tried code from other places on stackexchange but I can't seem to get it to work.

I linked a whole bunch of libraries because I didn't know what the error was.

Here is the error in question, along with the line I used to compile the code:

1
  • to make 1000 a string rather than the integer, add double quotes around it. like "1000". Double quotes makes everything in them a stream of characters or a string. Aug 1 '15 at 19:42
2

Here on my Fedora Box and also in the appliance the man crypt has the following prototype of crypt:

char *crypt(const char *key, const char *salt);

I would say, that the 1000 in your call to crypt causes the clang error "incompatible integer to pointer conversion"

Try to use a string as salt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .