Unix - Filters and Commands

86:  

Choose the correct statement

A.

To read successive characters from an open file . getchar and scan f can be used interchangeably

B.

To read successive characters from an open file. getchar and read can be used interchangeably

C.

The read system call reads from the buffer

D.

None of the above

 
 

Option: A

Explanation :

All the library i /o functions (like getchar, scanf , gets etc.) use the same interme-diate buffer and share the same file pointer. So, they can be interleaved in any order to access consecutive characters in a tile without causing any inconsistency. Unlike them. system calls (like read and write) directly manipulate the tile. So, mixing system calls and library function will have undesired consequence

Click on Discuss to view users comments.

Write your comments here:



87:  

 The following program
main()
{
close(1);
print("How R U?");
}

A.

is syntactically incorrect

B.

results in a run-time error

C.

will wait indefinitely, if executed

D.

none of the above

 
 

Option: D

Explanation :

The close statement closes the file, whose Tile descriptor is 1, i.e., stdout. So, print f will fail. So. the program immediately terminates.

Click on Discuss to view users comments.

Write your comments here:



88:  

 Choose the correct remarks

A.

exit and return can be used interchangeably

B.

Use of return terminates the program

C.

Use of exit terminates the program

D.

exit retuns a value to the system

 
 

Option: D

Explanation :

return statement when executed transfers control back to the calling environment. So, if a subroutine executes a return statement control comes back to the main routine. exit always terminates the program, which means within the main routine, exit and return can be used interchangeably.

Click on Discuss to view users comments.

Write your comments here:



Related MCQ