美文网首页
Random String

Random String

作者: KGBer | 来源:发表于2016-05-19 22:02 被阅读0次
// 字符串长度,16Byte
const int length = 16;

char ch[length + 1];

ch[length] = '\0';

for (int i = 0; i < length; i++) {

    // 根据 ASCII 取 33~126 之间的符号    
    ch[i] = 33 + arc4random() % 94;
}

NSString *string = [NSString stringWithUTF8String:ch];

相关文章

网友评论

      本文标题:Random String

      本文链接:https://www.haomeiwen.com/subject/kkigrttx.html