以下是我列举的各种情况:
小心看晕!!!!!- int a = 5;
- float b = 2.3f;
- double c = 3.14;
- char d = 'x';
- char * e = "张三丰!";
- NSString *str1 = @"黄飞鸿";
-
- printf("a = %d\n", a); //a =5;
- printf("b = %.2f\n",b); //b =2.30
- printf("c = %.2f\n",c); //c =3.14
- printf("d = %c\n", d); //d =x
- printf("e = %s\n", e); //e =张三丰!
- //printf("str1 = %s\n", str1);//错误
-
- NSLog(@"a = %d", a); //a =5;
- NSLog(@"b = %.2f",b); //b =2.30
- NSLog(@"c = %.2f",c); //c =3.14
- NSLog(@"d = %c", d); //d =x
- NSLog(@"e = %s", e); //e =打印不出来
- //NSLog(@"e = %@", e); //e =报错
- //NSLog(@"str1 = %s", str1); //str1 =乱码
- NSLog(@"str1 = %@", str1); //str1 =黄飞鸿
复制代码
|
|