Probably there are some differences between Windows and UNIX ... in this second case, s_addr has the lower case.
Type: Posts; User: dancp
Probably there are some differences between Windows and UNIX ... in this second case, s_addr has the lower case.
I ran the code as above and the print is 1010f6 and I don't know hot it represents (I think it's a memory address) ...
sockin.sin_addr (where sockin is a sockaddr_in) IS an in_addr ... I really don't understand why it doens't work ...
I tried, but it doesn't work again.
int main(int argc, char **argv) {
struct hostent *hp;
char *addr = "www.google.com";
hp = gethostbyname(addr);
//just a little "debug"
if...
Ops, I forgot to tell I'm programming in UNIX.
But I think inet_ntoa() is present, anyway.
How can I print an IP address contained in a struct hostent obtained by a gethostbyname() call?
I simply tried a
printf("%s", hos->h_addr);
(where hos is a pointer to a struct hostent...
Thank you for the replies!
I thought it was a memory access problem caused by the pointer (in the first case).
In the second case, I put the string into a chars vector. Isn't a literal, in this...
When I write some lines as
int main(int argc, char **argv) {
char *string = "Bla0 Bla1 Bla2 Bla3";
char *temp;
temp = strtok(string, " ");
}
I've an invalid address error on the strtok...