33 พิมเขียวข้อมูล ( structure )


  • structure : คือชนิดข้อมูลที่คุณเป็นผู้สร้างเอง
  • structure : ชนิดข้อมูลที่คุณสร้างขึ้นเองนั้น ทำได้โดยการรวมชนิดข้อมูลพื้นฐาน มาจัดไว้เป็นกลุ่น และตั้งชื่อใหม่
  • ชื่อของ struct (ชื่ออะไรก็ตาม) จะถูกเรียกว่า tag หรือ type name

#include <stdio.h>
int main(void)
{
struct student { char name[20] ; int age; } std1 = {"Emily", 18};
struct student std2 = {"Nadia", 19};
printf("%s , %d\n" , std1.name , std1.age);
printf("%s , %d\n" , std2.name , std2.age);
return 0;
}
view raw B33_Structure.c hosted with ❤ by GitHub