my program doesn't return any errors but if u compile it (please do)
u will see that something is wrong. i think is because of the 'gets' function i used but i can't use the 'scanf' function because it only reads the first word please help me resolve this problem.It would be deeply appreciated.
Code:
#include<stdio.h>
#include<conio.h>
struct product
{
char name[30];
int stock;
float price, discount;
};
void main()
{
struct product p[3];
int i;
float temp;
// clrscr();
for(i=0;i<3;i++)
{
printf("Enter product name :");
gets(p[i].name);
printf("\nEnter Stock :");
scanf("%d",&p[i].stock);
printf("\nEnter Price :");
scanf("%f",&temp);
p[i].price = temp;
printf("\nEnter Discount :");
scanf("%f",&temp);
p[i].discount = temp;
printf("\n\n");
// fflush(stdin);
}
// clrscr();
for(i=0;i<3;i++)
{
printf("Name=%s, Stock=%d, Price=$%.2f, Discount=%.2f%.\n", p[i].name, p[i].stock, p[i].price,p[i].discount);
}
getch();
}