Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assignment makes integer from pointer without a cast

Status
Not open for further replies.

Chandhru

Technical User
Jun 12, 2003
77
US
Hi,

I am trying to compile my client code developed in C language. i am retrieving argv values for my server address and port name, but i get the following error."assignment makes integer from pointer without a cast".
my compiler is Solaris.

why do i get this error. please help

for example , the following lines returns the error

hostname = *argv[1];
data ="PING";
port =atoi(argv[2]);



 
It would really help if you provided declarations for postname, data and port. However, assuming that argv is the 2nd argument to main(), it should be:

char *hostname;
int port;
char *data;

hostname = argv[1]; /* this is probably where you're getting the error */
data = "PING";
port = atoi(argv[2]);
 
i think u need to do a string copy instead of simple
assignment

strcpy(hostname,argv[1]);

other assignments are quite valid and must not cause any error unless the declarations are correct!
 
> strcpy(hostname,argv[1]);
Which is the worst thing you can do if hostname is presently an uninitialised pointer.

Stick with dlkfjdlkfjdlfkd's suggestions

> for example , the following lines returns the error
Only one of those lines produces the error.
Every error generated by the compiler has a line number associated with it. Figure out how to goto a line number in your text editor and study carefully.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top