Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将其转换为 192 作为整数值?
NSString* hex = @"c0";
或者我有char a1 = **'\xc0';**如何将其转换为int?我不能在 Xcode 中使用 atoi。:(
char a1 = **'\xc0';
int
谢谢
你有两种选择,一种是 C 风格,一种是 Objective-C,第一种类似于
long value = 0; sscanf_s([hex cStringUsingEncoding:NSUTF8StringEncoding], "%x", &value);
后者类似于
long value = 0; NSScanner *scanner = [NSScanner scannerWithString:hex]; [scanner scanHexInt:&value];