Skip to content

Instantly share code, notes, and snippets.

@colourful987
Last active May 30, 2017 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colourful987/4df8ea9c215c881ccfc079e05e92bd25 to your computer and use it in GitHub Desktop.
Save colourful987/4df8ea9c215c881ccfc079e05e92bd25 to your computer and use it in GitHub Desktop.
三种初始化结构体的方式
struct student{
const char *name;
int age;
char tag;
};
int main(int argc, const char * argv[]) {
// 方式一
struct student st_student1 = {"Alan",10,'1'};
// 方式二
struct student st_student2 = {
.name = "梁杰",
.age = 20,
.tag = '0'
};
// 方式三 Xcode 中不允许这种方式
struct student st_student3 = {
name:"pmst",
age:23,
tag:'-1'
};
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment