标签:style blog color ar div sp log on c
//学生结构体 typedef struct student { char name[20]; //姓名 char sex; //性别 int age; //年龄 }Student; int main(int argc, const char * argv[]) { Student stu={"xiaorui",‘f‘,24}; NSValue *structObject={0};
//将结构体转换为对象 structObject=[NSValue value:&stu withObjCType:@encode(Student)]; NSLog(@"%@",structObject); //将对象转换为结构体 Student stu2={0}; [structObject getValue:&stu2]; NSLog(@"%s %c %d",stu2.name,stu2.sex,stu2.age);
return 0; }
标签:style blog color ar div sp log on c
原文地址:http://www.cnblogs.com/haili/p/3966996.html