Ok, I got it working thanks to Sean and Mike. Just a question. The man
page for crypt says it returns a pointer to char, but when I compile it,
it gives me a warning.
brian@darkstar:~/src/C/c_files> gcc crypt_test.c -o crypt_test -lcrypt
crypt_test.c: In function `main':
crypt_test.c:18: warning: assignment makes pointer from integer without a cast
Below is the form which I received the warning. I changed the char
array that receives the result to a char pointer, so I wouldn't be
taking unnecessary memory. Thanks mike for that note on the dynamic mem
allocation with the crypt function.
brian@darkstar:~/src/C/c_files> cat crypt_test.c
/* Filename: crypt_test.c
*/
#include <stdio.h>
#define _XOPEN_SOURCE
#include <unistd.h>
int main (void)
{
char input[255];
char *output;
char salt[2];
strcpy(salt,"abcde");
strcpy(input,"My blue heaven");
output = crypt(input, salt);
printf("Hello crypt %s \n", output);
}
On Thu, Oct 21, 1999 at 05:44:12PM -0700, I originally wrote:
> I am trying to get this simple C program to work and no go. What
> am I doing wrong?
>
>
> /* Filename: crypt_test.c
> */
>
> #include <stdio.h>
> #define _XOPEN_SOURCE
> #include <unistd.h>
>
> int main (void)
> {
>
> char input[255];
> char output[255];
> char salt[2];
>
> strcpy(salt,"ab");
> strcpy(input,"My blue heaven");
>
> output = crypt(input, "AB");
>
> printf("Hello crypt %s \n", output);
> }
-- Brian Lavender http://www.brie.com/brian/
This archive was generated by hypermail 2b29 : Fri Feb 25 2000 - 14:29:07 PST