Skip to study material

Unit II · Viva Questions

Revise the concepts orally; open a study answer when you need more detail.

← Unit questions

Explain files, FILE pointers, opening modes and closing.

Does fclose remove the stored file?
No.
Which mode would unexpectedly erase an existing file’s contents?
w, and similarly w+ when opening succeeds.
Study this concept →

Explain character, formatted and line-based text file input/output.

Why store fgetc in int rather than char?
To preserve the distinction needed for EOF.
Does fputs automatically add a newline?
No.
Study this concept →

Compare text and binary file processing.

Does saving a pointer save the linked objects?
No.
Is a native fwrite structure file universally portable?
No. Layout and representation can differ.
Study this concept →

Explain fread and fwrite with a binary-file example.

What should a short fread result trigger?
Handle only completed elements and determine whether end or an error caused the short result.
Which modes are used here?
wb for writing and rb for reading.
Study this concept →

Explain feof, ferror and clearerr and correct end-of-file testing.

Is EOF a data byte stored at every file’s end?
No.
Does clearerr repair a failed disk?
No. It only clears stream indicators.
Study this concept →

Explain file positioning with fseek, ftell, rewind, fgetpos and fsetpos.

Which origin refers to the file beginning?
SEEK_SET.
Is a text ftell result always an ordinary byte count?
No.
Study this concept →

Explain argc and argv with a checked numeric-argument example.

Are argv entries already integer values?
No. They are strings.
Why check the end pointer after strtol?
To detect missing digits or leftover characters.
Study this concept →

Explain multifile programming, headers, declarations and linking.

Does including a header link the missing function definition?
No.
Where should a normal shared function have its external definition?
In one appropriate source file.
Study this concept →

Explain append and update streams and safe transitions between reading and writing.

Does fseek let append-mode writes overwrite the middle?
Append-mode writes still go to the end.
What transition is normally needed after input before output?
A suitable file-positioning operation, except for the specified end-of-file case.
Study this concept →