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
|
请发表评论