• c语言基础, , ,


    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遇到 时,或者缓冲区满时,才会将缓冲区里的内容刷新到标准输出(stdout).

     = CR (Carriage Return) // Used as a new line character in Mac OS before X

     = LF (Line Feed) // Used as a new line character in Unix/Mac OS X

     = 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
    123", s);
    //    fflush(stdout);
        return 0;
    }
                                                                      
    

      

    是另起一行, 的话回到本行的开头,如果继续输入的话会把先前的覆盖掉

    比如printf("asdflkj 111")输出的是111flkj

  • 相关阅读:
    电脑快捷键
    方法
    运算符和表达式
    Java关键字和标识符
    字体和文本
    盒子模型
    css
    常用标签
    第一次课(上)
    出现次数最多的数字
  • 原文地址:https://www.cnblogs.com/oxspirt/p/9927884.html
Copyright © 2020-2023  润新知