Enumeration (or enum) in C
Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain.
enum State {Working = 1, Failed = 0};
定義枚舉類型:
Variables of type enum can also be defined. They can be defined in two ways:
// In both of the below cases, "day" is
// defined as the variable of type week.
enum week{Mon, Tue, Wed};
enum week day;
// Or
enum week{Mon, Tue, Wed}day;
https://www.geeksforgeeks.org/enumeration-enum-c/
//在linux系統下,printf函數是行緩沖式的輸出,當printf遇到\n時,或者緩沖區滿時,才會將緩沖區里的內容刷新到標准輸出(stdout).
\r = CR (Carriage Return) // Used as a new line character in Mac OS before X
\n = LF (Line Feed) // Used as a new line character in Unix/Mac OS X
\r\n = CR + LF // Used as a new line character in Windows
#include <stdio.h>//這一行不加也可以,但是會有警告。
enum State {Working = 1, Failed = 0};
int main(){
enum State s;
s = Working;
printf("%daaaaaa\r123", s);
// fflush(stdout);
return 0;
}
\n是另起一行,\r的話回到本行的開頭,如果繼續輸入的話會把先前的覆蓋掉
比如printf("asdflkj\r111")輸出的是111flkj
