iOS格式化字符串

        //%@ 字符串输出
        //%% 输出%这个字符
        int a = -1;
        NSLog(@"有符号32输出=%d",a);
        NSLog(@"有符号32输出=%D",a);
        NSLog(@"有符号32输出=%i",a);
        
        unsigned int b = 2;
        NSLog(@"无符号32输出=%u",b);
        NSLog(@"无符号32输出=%U",b);
        
        short int c = 3;
        NSLog(@"有符号16输出=%hi",c);
        unsigned short int d = 4;
        NSLog(@"无符号16输出=%hu",d);
        
        long long e = 5;
        NSLog(@"有符号64输出=%qi",e);
        unsigned long long f = 6;
        NSLog(@"无符号64输出=%qu",f);
        
        unsigned int g = 7;
        NSLog(@"无符号32位16进制小写输出=%x",g);
        NSLog(@"无符号32位16进制大写输出=%X",g);
        
        unsigned long long h = 8;
        NSLog(@"无符号64位16进制小写输出=%qx",h);
        NSLog(@"无符号64位16进制大写输出=%qX",h);
        
        unsigned int i = 9;
        NSLog(@"无符号64位8进制小写输出=%o",i);
        NSLog(@"无符号64位8进制小写输出=%O",i);
        
        double j = 10;
        NSLog(@"有符号64位双精度输出=%f",j);
        NSLog(@"有符号64位双精度科学计数法小写输出=%e",j);
        NSLog(@"有符号64位双精度科学计数法大写输出=%E",j);
        
        double k = 1000000;
        NSLog(@"有符号64位双精度智能科学计数输出=%g",k);
        NSLog(@"有符号64位双精度智能科学计数输出=%G",k);
        
        unsigned char l = 65;
        NSLog(@"8位=%c",l);
        
        unichar m = 0x0042;
        NSLog(@"16位=%C",m);
        
        char *n = "hello world";
        NSLog(@"8位=%s",n);
        
        NSString *p = @"p";
        NSLog(@"指针:%p",p);

 

posted @ 2016-06-14 14:09  土车  阅读(803)  评论(0)    收藏  举报