开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜