- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_viewFrame = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
[_viewFrame setBackgroundColor:[UIColor yellowColor]];
_viewFrame.bounds =CGRectMake(-50, -50, 200, 200);
NSLog(@"x=%f y=%f w=%f h=%f",_viewFrame.frame.origin.x,_viewFrame.frame.origin.y,_viewFrame.frame.size.width,_viewFrame.frame.size.height);
NSLog(@"x=%f y=%f w=%f h=%f",_viewFrame.bounds.origin.x,_viewFrame.bounds.origin.y,_viewFrame.bounds.size.width,_viewFrame.bounds.size.height);
[self.view addSubview:_viewFrame];
char *a = "abc";
char *rever(char *dest,const char *src);
char *b = (void *)malloc(strlen(a)+1);
memset(b, 0x00, sizeof(strlen(a)+1));
// 注意这里:对malloc的buf进行初始化
NSLog("%s\n", rever(b,a));
}
char *rever(char *dest,const char *src)
{
int n;
char *temp = dest; // 注意这里:用来记录dest的初始地址
for ( n = strlen(src)-1;n>=0;dest++,n--){
*dest = *(src+n);
}
return temp; // 注意这里:返回dest字符串的首地址
}