[OCLUG-devel] pointer from integer without a cast
Christopher Smith
x at xman.org
Tue Sep 13 13:17:29 PDT 2005
Doug Jolley wrote:
> I've been playing around trying to get crypt to work. I have a little
> test program that I'm using which I am appending to this message. When
> I try to compile the test program I get a compiler warning that the
> assignment makes a pointer from an integer without a cast. I actually
> think I understand the thrust of what that message is trying to tell
> me. The problem is that I don't think I'm doing what it's complaining
> about. My understanding is that the crypt function returns a pointer to
> charactger. If that's the case; then, I'm assigning a pointer to a
> pointer and I don't understand the complaint. Any ideas on what I'm
> missing?
>
> Thanks for any input.
>
> ... doug
> - - - - - - - - - - - - - - - - - Test Program - - - - - - - - - - - - - - -
> #include <stdio.h>
> #include <unistd.h>
> int main() {
> char *p2epw;
> p2epw=crypt("blackjack","00");
> printf("Encrypted PW: %s\n",p2epw);
> return 0;
> }
Try this:
#define _XOPEN_SOURCE
#include <stdio.h>
#include <unistd.h>
int main() {
char *p2epw;
p2epw=crypt("blackjack","00");
printf("Encrypted PW: %s\n",p2epw);
return 0;
}
--Chris
P.S.: As a general rule, errors like that should make you think that you
don't have the right function prototype included. The trick is figuring
out why.
More information about the OCLUG-devel
mailing list