Structure II 1 Structure 1 1 Structure Variable
Structure II. ទមរងន ក របងក ត 1. ទមរងន ក របងក ត Structure ម នពរ : 1. 1 Structure គម ន Variable q Syntax structure_name { data_type member 1; data_type member 2; . . data_type memeber; };
Structure q បរយ យ q struct: គជ keyword ដ លបរ សរ បបងក ត q struct_name: ជ ឈម របស q datatype member: គជ ក របងក ត Structure។ Variable ន កនង struct
Structure q ឩទ ហណ struct person { int person_no; char name[50]; float salary; };
Structure 1. 2 q ក របងក ត Variable ន កនង Structure Syntax: structure_name variable 1, variable 2, …. . , variable n; q ឩទ ហណ struct person { int person_no; char name[50]; float salary; } p 1 , p 2 , p[20]; p 1, p 2, p[20] : ម ននយថ រចជ សរ ចដ យមនច ប ច q ក របរក ស instant Variable ដ លប ន Instant(បងក ត ) ន កនង main() function ទ ។ ន កនង sruct
Structure q ក របរ បរ ស Structure ដ លម ន Variable ន struct ក របរ បរ ស Variableរបស Struct
Structure q Embeded Structure
Structure III. ក របរ បរ ស structure នង pointer #include <stdio. h> struct name printf("Enter integer: "); scanf("%d", &(*ptr). a); { int a; float b; }; printf("Enter number: "); void main() scanf("%f", &(*ptr). b); { printf("Displaying: "); struct name *ptr, p; ptr=&p; /* Referencing pointer to memory address of p */ printf("%d%f", (*ptr). a, (*ptr). b); return 0; }
Structure
Structure
- Slides: 14