In C a structure is passed to a function by value. This means that the structure valued is copied for processing in the body of the function. Therefore any changes made to the value by the function would not give any effect on the value of the structure Any idea for me to insert the function void for this program..
#include<stdio.h>
struct book{
char title[80];
int bar_code;
float price;
};
struct book BOOK;
float price2,discount;
void main(){
struct book *ptr;
ptr = &BOOK;
clrscr();
printf("Title:");
/**scanf("%s", &ptr->title);**/
gets(ptr->title);
printf("bar code:");
scanf("%d", &ptr->bar_code);
printf("Price:");
scanf("%f", &ptr->price);
price2 = ptr->price;
if (price2>=100) {
discount =price2-(price2*0.10);
printf("discount price:%.2f",discount);
}
printf("-----------------------\n");
printf("%s\n", ptr->title);
printf("%d\n",(*ptr).bar_code);
printf("Before Discount:%.2f\n", ptr->price);
printf("After Discount:%.2f\n", discount) ;