Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include struct Invoice { char customerName [ 5 0 ] ; int customerId; char dateOfPurchase [ 1 0 ] ; float amountOfPurchase; int billNumber; }

#include
struct Invoice {
char customerName[50];
int customerId;
char dateOfPurchase[10];
float amountOfPurchase;
int billNumber;
};
int main(){
FILE *file = fopen("invoice.txt","rb"); // Open in binary read mode
struct Invoice bill;
int billNumberToSearch;
if (file == NULL){
perror("Error opening the file");
return 1;
}
printf("Enter bill number to search: ");
scanf("%d", &billNumberToSearch);
while(fread(&bill, sizeof(struct Invoice),1, file)){
if(bill.billNumber == billNumberToSearch){
printf("Customer Name: %s
", bill.customerName);
printf("Customer ID: %d
", bill.customerId);
printf("Date of Purchase: %s
", bill.dateOfPurchase);
printf("Amount of Purchase: %.2f
", bill.amountOfPurchase);
printf("Bill Number: %d
", bill.billNumber);
fclose(file);
return 0;
}
}
printf("No bill found with the given number.
");
fclose(file);
return 0;
}
what is the output for this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

Compute E[B(t1)B(t2)B(t3)] for t1 Answered: 1 week ago

Answered: 1 week ago

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago