使用结构中的成员变量在oc 中进行数据传递

//

//  ViewController.m

//  tttttttt

//

//  Created by 张凯泽 on 16/1/20.

//  Copyright © 2016年 rytong_zkz. All rights reserved.

//

 

#import "ViewController.h"

typedef struct {

    char * name;

    char * sex;

    int age;

}Person;

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    Person p;

    p.name = "zkz";

    p.age = 34;

    p.sex = "nan";

    //printf("%s\n",p.name);

    [self test:p.name];

    [self test1:p.age];

    [self test2:&p];

    char ch[5];

    ch[0] = 45;

    

    

    

}

-(void)test:(char*)ch

{

    NSString * ss = [[NSString alloc]initWithCString:ch encoding:NSUTF8StringEncoding];

    NSLog(@"%@",ss);

    

}

-(void)test1:(int)age

{

    NSLog(@"%d",age);

}

-(void)test2:(Person*)pp

{

    NSString * ss = [[NSString alloc]initWithCString:(*pp).name encoding:NSUTF8StringEncoding];

    NSLog(@"%@",ss);

 

}

@end

 

posted @ 2016-01-21 20:44  张凯泽  阅读(139)  评论(0编辑  收藏  举报