开发者

How to get inout to an NSString?

How to get input from an NSString as scanf开发者_如何学Go ("%@", &str); doesn't work?


scanf will read into a C string and not into a NSString (as far as I know). So, to do what you're trying to do you need to first read your input into a C string (i.e. str) and then make that into an NString as follows

myString = [NSString stringWithUTF8String:str];

By the way, you don't need to pass the address of str i.e. &str if str is an array. Simply do:

scanf("%s",str);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜