/* Note:Your choice is C IDE */
#include "stdio.h"
struct stu_rec {
char name[15];
float iscore;
};
int main(void)
{
struct stu_rec student;
printf("please enter the names.\n");
gets(student.name);
printf("now enter the iscore.\n");
scanf("%f",&student.iscore);
printf("%c %f",student.name,student.iscore);
return 0;
}
2:多个变量
/* Note:Your choice is C IDE */
#include "stdio.h"
struct stu_rec {
char name[15];
int iscore;
};
int main(void)
{
struct stu_rec student[6];
int i;
for(i=0;i<6;i++){
printf("please enter the name.\n");
scanf("%s",&student[i].name);
printf("now enter the iscore.\n");
scanf("%d",&student[i].iscore);}
for(i=0;i<6;i++)
printf("%s %d\n",student[i].name,student[i].iscore);
return 0;
}