Enum ใน c

รหัสตัวอย่าง

5
0

เป็น enum ข้อมูลประเภทในซี

// An example program to demonstrate working 
// of enum in C 
#include<stdio.h> 
  
enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun}; 
  
int main() 
{ 
    enum week day; 
    day = Wed; 
    printf("%d",day); 
    return 0; 
}  
// OUTPUT
2
3
0

วิธีที่จะกำหนด enum ใน c

//enum <name of enumeration> { <possible choices separated by commas> } 
enum type_of_fuel{ Gasolina, Gasoleo, Hibrido, Eletrico};
2
0

enum c

// Changing default values of enum constants
enum suit {
    club = 0,
    diamonds = 10,
    hearts = 20,
    spades = 3,
};
0
0

เป็น enum ข้อมูลของพิมพ์ c บว

// example program to demonstrate working 
// of enum in C 
#include<stdio.h> 
  
enum year{Jan, Feb, Mar, Apr, May, Jun, Jul,  
          Aug, Sep, Oct, Nov, Dec}; 
  
int main() 
{ 
   int i; 
   for (i=Jan; i<=Dec; i++)       
      printf("%d ", i); 
        
   return 0; 
} 


// OUTPUT
0 1 2 3 4 5 6 7 8 9 10 11

หน้าคล้ายกัน

คล้ายกันหน้ากับตัวอย่าง

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................