Given the output of the following command:
§ 1s -1 xVz
– 1 jas jas 2803 Mar 27 21:12 xyz
If a user other than jas runs the following code, in the directory containing xyz
Copyright By PowCoder代写 加微信 powcoder
int fd = open (“xyz”, O RDONLY) ;
if (fd < 0) {
perror (NULL) ;
what will be the resulting error message?
"No such file or directory
"Permission denied"
"Segmentation fault"
There is no error, so there will be no error message
The call to perror ) will fail, because of the NULL argument, and produce no message
None of the other answers is correct
Consider a file of records of the following type:
typedef struct {
// unique identifier
desc[100]; // description of item
float price;
// wholesale price
And the following variables:
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
leek(fd, 10*sizeof (Record), SEEK SET) ;
write(fd, &rec, sizeof (Record)) ;
1seek(fd, 10, SEEK_SET);
write(fd, &rec, sizeof (Record));
1seek(fd, 10*sizeof (Record), SEEK_CUR);
write(fd, rec, sizeof (Record)) ;
Consider the following function call which attempts to write 100 bytes from a buffer buf to a file fd, where fd is
open for writing:
write(fd, &buf[0], 100) ;
Which of the following are possible return values from the function call?
either 0 or 100
any value in the range 0..100
either -1 or 0 or 100
-1 or any value in the range 0..100
None of the other options is correct
If I were writing a C program to read a file containing binary data that I had opened in the following way:
FILE * £ = open ("abc", "r");
I would read the file using
fgets or fscanf
fgetc or fread
It is not possible to read in data from a binary file in a c program
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com