整數
int a = 10;
浮點數
double a = 10.0;
字串
const char *cs = "abcdefg";
char *s = "abcdefg"; // 編譯器會發出警告,這和c++記憶體模型有關
陣列
int array[] = {1,2,3,4,5};
const int carray[5] = {1,2,3,4,5};
結構初始化
struct People{
int age;
const char *name;
};
struct People p = { 10, "sean" };
指標初始化
int a = 10;
int *b = &a;