Problem with array of structures
Hey guys. Please have a look at this code. I'm not gettin the expected output... Please help.
Code:
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
struct book
{
char name;
float price;
int pages;
};
struct book b[2];
int i;
for(i=0;i<2;i++)
{
printf("\nEnter name, price and pages");
scanf("%c %f %d", &b[i].name, &b[i].price, &b[i].pages");
}
for(i=0;i<2;i++)
printf("%c %f %d", b[i].name, b[i].price, b[i].pages");
getch();
}
///// This section is included to avoid Linker Error
linkfloat()
{
float a=0, *b;
b=&a;
a=*b;
}
/// This section is included to avoid Linker Error
Input given is(for eg)
s 456 234
d 456 889
output
s 456.00000 234
garbage value