Mcq modul 03:Correct ans
The low‑level open() function, when succeeded, returns:
a pointer to file descriptor
Correct!
an int being a file descriptor
an int being an error code
a pointer to error code
Question 2
1 / 1 pts
Which snippet will you use to delete file named "file"?
Correct!
unlink("file");
open("file",O_DELETE);
FILE *f=fopen("file","rw"); unlink(f); fclose(f);
int fd=open("file",O_RDWR); unlink(fd); close(fd);
Question 3
1 / 1 pts
The descriptor of value equal to 0:
is not connected and may be freely used
Correct!
is connected to stdin
is connected to stderr
is connected to stdout
Question 4
1 / 1 pts
The "endline translation" occurs:
when the file is opened with O_TEXT and O_BINARY flags ored (|) together
when the file is being created
when the file is opened with O_BINARY flag
Correct!
when the file is opened with O_TEXT flag
Question 5
1 / 1 pts
To write all elements of array declared below you may use the invocation:
double vec[3\] = { -1., 1., 0};
write(fh, sizeof(vec), vec);
Correct!
write(fh, vec, sizeof(vec));
write(fh, 3, vec);
write(fh, vec, 3);
Question 6
1 / 1 pts
The close() function:
always succeeds
is of void type
Correct!
may not succeed
does not return any useful value
Question 7
1 / 1 pts
The stat() function:
is fully supported in all operating systems
is named Stat() in non-Unix operating systems
is not accessible in non-Unix operating systems
Correct!
is partially supported in non-Unix operating systems
Question 8
1 / 1 pts
The readlink() function:
gets all names of the link
Correct!
gets a name of file pointed by the link
gets all names of the file pointed by the link
reads a file pointed by the link
Question 9
1 / 1 pts
The fcntl() function:
is able to change some of the access modes specified during open() function invocation
must not be used when it comes to regular file's access modes
Correct!
is not able to change access mode specified during open() function invocation
is able to change access mode specified during open() function invocation
Question 10
1 / 1 pts
The dprintf() function is designed to:
print the formatted strings to two streams in the same time
delete stream content
print doubles instead of floats
Correct!
use file descriptor instead of FILE * pointer
Question 11
1 / 1 pts
What should be placed instead of <?> to make the following snippet work properly?
int fd = open("input", O_WRONLY);
if( <?> ) {
puts("File could not be open");
exit(1);
}
fd == NULL
fd > 0
Correct!
fd < 0
fd == 0
Question 12
1 / 1 pts
The O_CREATE flag, used by the open() function, has the following effect:
if the file exists, it will be truncated to zero
if the file exists, it will be erased and created again
Correct!
if the file not exists, it will be created
if the file not exists, the open() function will fail
Question 13
1 / 1 pts
The fileno() function:
Correct!
extracts a file descriptor from the given FILE structure
counts all currently open file descriptors
creates a new file descriptor
puts a file descriptor into the given FILE structure
Question 14
1 / 1 pts
How many bytes will the following program write to a file, assuming that the code is compiled by CL compiler and successfully ran on MS Windows?
#include <io.h>
#include <fcntl.h>
int main(void) {
char buff[] = "ABC\n";
int fd = open("file", O_WRONLY | O_CREAT | O_TEXT);
write(fd, buff, strlen(buff));
close(fd);
return 0;
}
4
3
Correct!
5
0
Question 15
1 / 1 pts
The "st_ino" field of the "struct stat":
Correct!
has now meaning in MS Windows
is emulated in MS Windows
is fully supported in MS Windows
is always -1 in MS Windows
Question 16
1 / 1 pts
The so‑called EPOCH time is a number of seconds elapsed from 00:00:00 UTC, 1 January:
1960
1980
1990
Correct!
1970
Question 17
1 / 1 pts
The "st_mode" field of "struct stat" in MS Windows environment determines the state of "executable" attribute:
using owner's permissions
Correct!
using file's name
using owner's name
using file's permissions
Question 18
1 / 1 pts
To create a link in MS Windows environment you may use the function named:
makesymlink()
Correct!
CreateSymbolicLink()
createsymlink()
symlink()
No comments:
Post a Comment