enum Enum Day Of Weeksun 1 mon tue



















![3. 3การใช คำสง typedef เพอสรางตวแปรชนด struct student ผานตวแปร typedef struct { char code[9]; char 3. 3การใช คำสง typedef เพอสรางตวแปรชนด struct student ผานตวแปร typedef struct { char code[9]; char](https://slidetodoc.com/presentation_image_h2/3c76c017505a541833b3fe64a0d5f4eb/image-20.jpg)



![การกำหนดคาเรมตนใหกบตวแป ร struct CAR { char color[10] = “Black”; long price = 40000; } การกำหนดคาเรมตนใหกบตวแป ร struct CAR { char color[10] = “Black”; long price = 40000; }](https://slidetodoc.com/presentation_image_h2/3c76c017505a541833b3fe64a0d5f4eb/image-24.jpg)
![ตวอยาง : การกำหนดคาเรมตนใหกบตวแป ร struct CAR { char color[10] = “Red”; long price = ตวอยาง : การกำหนดคาเรมตนใหกบตวแป ร struct CAR { char color[10] = “Red”; long price =](https://slidetodoc.com/presentation_image_h2/3c76c017505a541833b3fe64a0d5f4eb/image-25.jpg)


![. 5การกำหนดคาคงทใหกบสมาชกของ structure struct STD { char code[9]; char name[31]; int midterm; int final; . 5การกำหนดคาคงทใหกบสมาชกของ structure struct STD { char code[9]; char name[31]; int midterm; int final;](https://slidetodoc.com/presentation_image_h2/3c76c017505a541833b3fe64a0d5f4eb/image-28.jpg)

![5. 2. การกาหนดคาของตวแปร ใหกบ structure เขยนไดดงน char co[9]=” 10015210”; strcpy(student. code, co); int x 5. 2. การกาหนดคาของตวแปร ใหกบ structure เขยนไดดงน char co[9]=” 10015210”; strcpy(student. code, co); int x](https://slidetodoc.com/presentation_image_h2/3c76c017505a541833b3fe64a0d5f4eb/image-30.jpg)
![6. อารเรยของ structure struct STD //สราง structure ชอ } char code[9]; char name[31]; int 6. อารเรยของ structure struct STD //สราง structure ชอ } char code[9]; char name[31]; int](https://slidetodoc.com/presentation_image_h2/3c76c017505a541833b3fe64a0d5f4eb/image-31.jpg)




- Slides: 35
ตวอยางการกำหนดคา enum Enum Day. Of. Week{sun=, 1 mon, tue , wen, thu, fri, sat ; { คาคอ sun=1, mon=2, tue=3, wen=4, thu=5 , fri=6 , sat = 7
ตวอยางการกำหนดคา enum Day. Of. Week{sun=, 1 mon, tue, wen=50, thu, fri, sat; { คาคอ sun=1, mon=2, tue=3, wen=50, thu=51 , fri=52, sat=53
. 3. 1การใช คำสง struct สรางตวแปรชนด โดยตรง student คอ ประกาศตวแปรไปพรอมกบการสราง struct STD { char code[9]; char name[31]; int midterm; int final; char grade; } student; struct product { int weight; float price; } apple, banana, melon;
3. 2การใช คำสง struct สรางตวแปรชนด student ผานตวแปร STD คอ ประกาศตวแปร หลงจากสราง struct STD แลว structure struct product { char code[9]; { int weight; char name[31]; int midterm; float price; int final; }; char grade; product apple; }; product banana, melon; STD student; // ����� Student ����� STD
3. 3การใช คำสง typedef เพอสรางตวแปรชนด struct student ผานตวแปร typedef struct { char code[9]; char name[31]; int midterm; int final; char grade; } STD; STD student; STD #define MAX_LEN 12 /* Length of name */ typedef struct { char name[MAX_LEN]; int id; float gpa; char major[10]; } product; product stu 1, stu 2, stu 3;
ตวอยางโปรแกรม typedef struct { int month, day, year; } DATE; void main( ) { DATE d 1; d 1. month = 12; d 1. day = 2; d 1. year = 1970; }
การกำหนดคาเรมตนใหกบตวแป ร struct CAR { char color[10] = “Black”; long price = 40000; } mycar; w [C++ Error] ………. cpp(6): E 2233 Cannot initialize a class member here
ตวอยาง : การกำหนดคาเรมตนใหกบตวแป ร struct CAR { char color[10] = “Red”; long price = 30000; } hiscar; w [C++ Error] ………. cpp(6): E 2233 Cannot initialize a class member here
. 5การกำหนดคาคงทใหกบสมาชกของ structure struct STD { char code[9]; char name[31]; int midterm; int final; char grade; }student, stud; ������� STD ������� student , stud �������
5. 1. กำหนดคาคงทใหกบ เขยนไดดงน structure strcpy(student. code, "40214514"); //เนองจากเปน string ตองใช strcpy() strcpy(student. name, "Somsak; (" student. midterm = 45 ; student. final = 30 ; student. grade=75 ;
5. 2. การกาหนดคาของตวแปร ใหกบ structure เขยนไดดงน char co[9]=” 10015210”; strcpy(student. code, co); int x = 25; student. midterm = x;
6. อารเรยของ structure struct STD //สราง structure ชอ } char code[9]; char name[31]; int midterm; int final; char grade; }; STD student[5]; //ประกาศตวแปรชอ student เปนอารเรยรายการ 5 STD
7. โครงสรางแบบซอนใน § โครงสรางอาจมการซอนกนไดเชน struc { date int int }; date; month; year; struc emprec { char name[21]; char address[21]; char town[21]; char postcode[9]; struc date start; } employee;