Last active
May 30, 2017 12:15
-
-
Save colourful987/4df8ea9c215c881ccfc079e05e92bd25 to your computer and use it in GitHub Desktop.
三种初始化结构体的方式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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