第14章 结构和其他数据形式
结构体
#include<stdio.h>
#define MAXTITL 41 //书名最大长度+1
#define MAXAUTL 31 //作者名的最大长度+1
struct book //结构体
{
char title[MAXTITL];
char author[MAXAUTL];
float value;
};
int main()
{
struct book library;
printf("Please enter the book title.\n");
gets(library.title);
printf("Now enter the quthor.\n");
gets(library.author);
printf("Now enter the value.\n");
scanf("%f", &library.value);
printf("%s:\"%s\"($%.2f)", library.author, library.title, library.value);
printf("Done!\n");
return 0;
}#include<stdio.h>
#defin