Question

Consider a file of records of the following type: typedef struct { int id; // unique...

Consider a file of records of the following type:

typedef struct {
   int   id;        // unique identifier
   char  desc[100]; // description of item
   float price;     // wholesale price
} Record;

And the following variables:

int    fd;  // file descriptor, open on file for read/write
Record rec; // record which is set to appropriate values

If the file is non-empty and fd is currently positioned at the end-of-file, which of the following pairs of statements will update the 11th record in the file fd with the value currently stored in rec?

None of the other options is correct

lseek(fd, 10*sizeof(Record), SEEK_SET);
write(fd, &rec, sizeof(Record));
lseek(fd, 10, SEEK_SET);
write(fd, rec, sizeof(Record));
lseek(fd, 10, SEEK_SET);
write(fd, &rec, sizeof(Record));
lseek(fd, 10*sizeof(Record), SEEK_CUR);
write(fd, rec, sizeof(Record));
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Answer:
lseek(fd, 10*sizeof(Record), SEEK_SET);
write(fd, &rec, sizeof(Record));
Add a comment
Know the answer?
Add Answer to:
Consider a file of records of the following type: typedef struct { int id; // unique...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code in C language ADT: typedef struct{ int ID; float salary; int age; }Employee; ...

    code in C language ADT: typedef struct{ int ID; float salary; int age; }Employee; Specification: In this lab, five functions need to be implemented using the given ADT. 1. Employee* readRecord(FILE*) This function receives a FILE pointer created before. It reads a line from the provided csv file, and creates an Employee struct pointer with the information from that line then returns the pointer back to the calling function. Each line in the provided csv file contains the id, salary,...

  • I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves...

    I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves the array of structures to file. It is already implemented for you. // You should understand how this code works so that you know how to use it for future assignments. void save(char* fileName) { FILE* file; int i; file = fopen(fileName, "wb"); fwrite(&count, sizeof(count), 1, file); for (i = 0; i < count; i++) { fwrite(list[i].name, sizeof(list[i].name), 1, file); fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...

  • Implement a program that: reads a number of personal records (for example, using PERSON struct from...

    Implement a program that: reads a number of personal records (for example, using PERSON struct from the earlier lab) from the standard input, creates a database of personal records, allows for adding new entries to the database, allows for deleting entries from the database, includes functions to acquire a record of personal data, and includes functions to display (print) a single selected record from the database, and also allows for printing all records in the database. NOTES: if name is...

  • IN C Programming #include<stdio.h> #include<stdlib.h> typedef struct nodestruct { int item; struct nodestruct *next; } Node;...

    IN C Programming #include<stdio.h> #include<stdlib.h> typedef struct nodestruct { int item; struct nodestruct *next; } Node; typedef struct { int size; // Number of items on user’s list Node *head, *tail; } List; //In addition to creating an empty list, this function will also create two dummy nodes; one for the head, and the other for the tail. List* createList(); //This function creates a node containing the provided item, then inserts it into the list pointed by the provided list...

  • 1. Assume the following struct is declared for the permission list of a file in Linux....

    1. Assume the following struct is declared for the permission list of a file in Linux. Each permission (u or g or o) is represented as an octal. For example, u=7 means rwx, u=5 means r-x. Note: "unsigned char" means a byte, not a character or a letter or a string. typedef struct { unsigned int uid; // owner id unsigned int gid; // group id unsigned char u; // owner's permission unsigned char g; // group's permission unsigned char...

  • Please, please help with C program. This is a longer program, so take your time. But...

    Please, please help with C program. This is a longer program, so take your time. But please make sure it meets all the requirements and runs. Here is the assignment: I appreciate any help given. Cannot use goto or system(3) function unless directed to. In this exercise you are to create a database of dogs in a file, using open, close(), read, write(), and Iseek(). Do NOT use the standard library fopen() ... calls! Be sure to follow the directions!...

  • C programming help! /* Your challenge is to format the following code in a readable manner, anwsering the questions in...

    C programming help! /* Your challenge is to format the following code in a readable manner, anwsering the questions in the comments. * */ #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <time.h> #include <sys/socket.h> #include <arpa/inet.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <strings.h> #define BUFFERT 512 #define BACKLOG 1 int create_server_socket (int port); struct sockaddr_in sock_serv,sock_clt; int main(int argc, char** argv){ int sfd, fd; unsigned int length = sizeof(struct sockaddr_in); long int n, m, count...

  • Consider a Linked List program with the following class: typedef int datatype; struct node {   datatype...

    Consider a Linked List program with the following class: typedef int datatype; struct node {   datatype data; node *tail; }; class LinkedList{ private: node *head; node *current;public: //constructors LinkedList(); LinkedList(int i); //destructor ~LinkedList(); bool start(); //sets list postion to header bool nextNode(); //increments to next node in list int getCurrent(); //returns data from current node void insertNode(int i); //inserts node after current node    //then sets current node to new node bool deleteNode();//deletes currentnode void deleteAll(); //deletes all nodes };...

  • URGENT. Need help editing some C code. I have done most of the code it just...

    URGENT. Need help editing some C code. I have done most of the code it just needs the following added: takes an input file name from the command line; opens that file if possible; declares a C struct with three variables; these will have data types that correspond to the data types read from the file (i.e. string, int, float); declares an array of C structs (i.e. the same struct type declared in point c); reads a record from the...

  • IrmaMoves.h : #include "IrmaMoves.h" typedef struct Move { Irma irma;            // an instance of Irma L...

    IrmaMoves.h : #include "IrmaMoves.h" typedef struct Move { Irma irma;            // an instance of Irma L Location from_loc; // location where Irma is moving from Location current_loc; // location where Irma is passing over Location to_loc; // location where Irma is moving to } Move; typedef struct Location { char col; // the square's column ('a' through 'h') int row; // the square's row (0 through 7) } Location; typedef struct Irma { int ws; // wind speed (MPH) int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT