Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A binary file stores a list of companys salaries. Each salary is stored as float. Which code fragment below will read the third salary of

A binary file stores a list of companys salaries. Each salary is stored as float. Which code fragment below will read the third salary of the file into a variable sal. The file is already opened using the file description fid.

a. fseek(fid, 0, SEEK_SET);

fread(&sal, sizeof(double), 1, fid);

b. fseek(fid, 0, SEEK_END);

rc = ftell(fid);

fseek(fid, rc - 3*sizeof(double), SEEK_END);

fread(&sal, sizeof(double), 1, fid);

c. fseek(fid, 0, SEEK_SET);

rc = ftell(fid);

fseek(fid, rc - 2*sizeof(double), SEEK_CUR);

fread(&sal, sizeof(double), 1, fid);

d. fseek(fid, 0, SEEK_SET);

fseek(fid, 2*sizeof(double), SEEK_CUR);

fread(&sal, sizeof(double), 1, fid);

e. None of the above

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

Step: 3

blur-text-image

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

1. Who will you assemble on the team?

Answered: 1 week ago

Question

4. Who would lead the group?

Answered: 1 week ago