v 1 typedef struct 2 int stuid 3

  • Slides: 14
Download presentation

การกำหนดขอมลใหกบตวแปรชนดโครงสราง v การกำหนดคาตองกำหนดใหถกตองตามชนดขอมลของสม 1. าชก typedef struct { 2. int stu_id; 3. char stu_name[20];

การกำหนดขอมลใหกบตวแปรชนดโครงสราง v การกำหนดคาตองกำหนดใหถกตองตามชนดขอมลของสม 1. าชก typedef struct { 2. int stu_id; 3. char stu_name[20]; 4. char stu_surname[20]; 5. }STUDENT; 6. STUDENT stu; 7. printf("Enter student ID: "); 8. scanf(“____", _____); 9. printf("Enter name: "); 10. scanf(“____", _____); 11. printf("Enter surname: "); 12. scanf(“____", ______); 13. printf("ID: %d, Name: %s, Surname: %s", stu_id, stu_name, stu_surname); } 10

ตวแปรชนดโครงสรางกบการใชอารเรย (ตอ ( 1. typedef struct { 2. int stu_id; 3. char stu_name[20]; 4.

ตวแปรชนดโครงสรางกบการใชอารเรย (ตอ ( 1. typedef struct { 2. int stu_id; 3. char stu_name[20]; 4. char stu_surname[20]; 5. }STUDENT; 6. STUDENT stu[5]; 7. for(i=0; i<5; i++){ 8. printf("Enter student ID: "); 9. scanf(“____", _____); 10. printf("Enter name: "); 11. scanf(“____", _____); 12. printf("Enter surname: "); 13. scanf(“____", ______); 14. printf("Added !nn"); 15. } 16. for(i=0; i<5; i++){ 17. printf("%d. ID: ____t. Name: ____t. Surname: ____n", i+1, __________, _____); 18. } 13

http: //www. renvi. src. ku. ac. th

http: //www. renvi. src. ku. ac. th