- 限定词 : long short unsigned
NSLog(@"size of int : %lu",sizeof(int)); // size of int : 4
NSLog(@"size of long int : %lu",sizeof(long int)); // size of long int : 8
NSLog(@"size of short int : %lu",sizeof(short int)); // size of short int : 2
NSLog(@"size of unsigned int : %lu",sizeof(unsigned int)); // size of unsigned int : 4
NSLog(@"size of long long int : %lu",sizeof(long long int)); // size of long long int : 8
NSLog(@"size of double : %lu",sizeof(double)); // size of double : 8
NSLog(@"size of long double : %lu",sizeof(long double)); // size of long double : 16
NSLog(@"size of float : %lu",sizeof(float)); // size of float : 4
long 可以扩展值域
short 节约内存
unsigned 用来存储正整数
- 整数相除
int a = 25;
int b = 2;
NSLog(@" a / b = %d",a/b); // a / b = 12
NSLog(@" a %% b = %d ",a%b); // a % b = 1
- 输入输出
int i = 0;
NSLog(@"请输入您的年龄: ");
scanf("%i",&i);
NSLog(@"您的年龄是: %d 岁",i);
- OC 使用的是消息结构而非函数调用,二者区别:
// 消息结构
Object *obj = [Object new];
[obj performWith:param1 and:param2];
// 函数调用
Object *obj = new Object;
obj->perform(param1,param2);
- 在一个类引用其它的类时最好是在.h文件中使用@类名,然后在.m文件中#import类即可
网友评论