結構體的定義
// 定義結構體st
struct st{
int a; // 成員a
int b; // 成員b
};
#include <stdio.h>
struct st{
int a;
int b;
};
int main()
{
struct st sst;
// 通過.來訪問結構體中的值
sst.a = 10;
sst.b = 20;
printf ("struct content is : %d, %d\n", sst.a, sst.b);
return 0;
}
輸出結果
struct content is : 10, 20
列舉型別
enum em{
red_color = 0;
green_color,
black_color
};
#include <stdio.h>
// 定義列舉型別,沒有定義默認從0開始,有值取值,無值默認上一個值加1
enum e_type{
red,
green,
blue
};
int main(int arc, char* argv[])
{
enum e_type et;
et = red;
printf ("the color is %d\n", et);
et = blue;
printf ("the color is %d\n", et);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/56880.html
標籤:C
