/*C語言 結構變數*/
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
struct data
//定義結構
{
char name[10];
int score;
}student;
puts("請輸入姓名:");
gets(student.name);
printf("請輸入分數:");
scanf_s("%d",&student.score);
printf("姓名:%s\n", student.name);
printf("分數:%d\n", student.score);
printf("sizeof(student):%d\n", sizeof(student));
system("pause");
return 0;
}
結果為:
文章標籤
全站熱搜