gethostbyname xcode issues
Hey guys, I'm new a开发者_运维技巧t this stuff, but I'm trying to use gethostname() to work using xcode and the ipad. I've tried a couple of things, but they all seem to freeze up.
So when I just do:
host = gethostbyname("website.com");
that works fine. I'd like to be able to change the website from within the program though.
I've tried:
const char *server = [Website_NSString UTF8String];
host = gethostbyname(server);
const char *server = [Website_NSString cStringUsingEncoding:NSASCIIStringEncoding];
host = gethostbyname(server);
const char *server[256];
[Website_NSString getCString:server maxLength:256 encoding:NSASCIIStringEncoding];
host = gethostbyname(Website_NSString);
and
host = gethostbyname(Website_NSString);
They've either come up with a the warning: Passing argument 1 of 'gethostbyname' from incompatible pointer type, or no warning at all. Still everytime the app just freezes. Please help.
I'm an idiot. If I do:
char server[256];
[Website_NSString getCString:server maxLength:256 encoding:NSASCIIStringEncoding];
host = gethostbyname(server);
It works fine.
精彩评论